add UUIDs to users as another way of identification
This commit is contained in:
parent
d9940a0462
commit
3546ddcc43
22
migrations/20170922234831_cleanup.js
Normal file
22
migrations/20170922234831_cleanup.js
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
exports.up = function (knex, Promise) {
|
||||
return Promise.all([
|
||||
knex.schema.table('users', (table) => {
|
||||
table.string('uuid', 36)
|
||||
}),
|
||||
knex.schema.table('news', (table) => {
|
||||
table.dropColumn('slug')
|
||||
})
|
||||
])
|
||||
}
|
||||
|
||||
exports.down = function (knex, Promise) {
|
||||
return Promise.all([
|
||||
knex.schema.table('users', (table) => {
|
||||
table.dropColumn('uuid')
|
||||
}),
|
||||
knex.schema.table('news', (table) => {
|
||||
table.string('slug')
|
||||
})
|
||||
])
|
||||
}
|
@ -6,6 +6,7 @@ import qs from 'querystring'
|
||||
import oauth from 'oauth-libre'
|
||||
import path from 'path'
|
||||
import url from 'url'
|
||||
import uuidV1 from 'uuid/v1'
|
||||
|
||||
const imgdir = path.join(__dirname, '../../', 'usercontent', 'images')
|
||||
|
||||
@ -48,7 +49,8 @@ const API = {
|
||||
let udataLimited = Object.assign({
|
||||
activated: 1,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
updated_at: new Date(),
|
||||
uuid: uuidV1()
|
||||
}, data)
|
||||
|
||||
// Check if the username is already taken
|
||||
|
@ -8,6 +8,7 @@ import crypto from 'crypto'
|
||||
import notp from 'notp'
|
||||
import base32 from 'thirty-two'
|
||||
import emailer from './emailer'
|
||||
import uuidV1 from 'uuid/v1'
|
||||
|
||||
import Promise from 'bluebird'
|
||||
const fs = Promise.promisifyAll(require('fs'))
|
||||
@ -350,6 +351,7 @@ const API = {
|
||||
let data = Object.assign(regdata, {
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
uuid: uuidV1(),
|
||||
activated: email ? 0 : 1
|
||||
})
|
||||
|
||||
|
@ -655,9 +655,9 @@ function newsPrivilege (req, res, next) {
|
||||
next()
|
||||
}
|
||||
|
||||
router.get('/news/compose', newsPrivilege, formKeep, wrap(async (req, res) => {
|
||||
router.get('/news/compose', newsPrivilege, formKeep, (req, res) => {
|
||||
res.render('news/composer')
|
||||
}))
|
||||
})
|
||||
|
||||
router.post('/news/compose', newsPrivilege, wrap(async (req, res) => {
|
||||
if (req.body.csrf !== req.session.csrf) {
|
||||
@ -708,11 +708,11 @@ router.get('/news/', wrap(async (req, res) => {
|
||||
}))
|
||||
|
||||
// Render partials
|
||||
router.get('/partials/:view', wrap(async (req, res, next) => {
|
||||
router.get('/partials/:view', (req, res, next) => {
|
||||
if (!req.params.view) return next()
|
||||
|
||||
res.render('user/partials/' + req.params.view)
|
||||
}))
|
||||
})
|
||||
|
||||
/*
|
||||
=========
|
||||
@ -720,10 +720,10 @@ router.get('/partials/:view', wrap(async (req, res, next) => {
|
||||
=========
|
||||
*/
|
||||
|
||||
router.get('/logout', wrap(async (req, res) => {
|
||||
router.get('/logout', (req, res) => {
|
||||
req.session.destroy()
|
||||
res.redirect('/')
|
||||
}))
|
||||
})
|
||||
|
||||
// User activation endpoint (emailed link)
|
||||
router.get('/activate/:token', wrap(async (req, res) => {
|
||||
|
@ -41,6 +41,7 @@ router.get('/user', oauth.bearer, wrap(async (req, res) => {
|
||||
|
||||
let udata = {
|
||||
id: user.id,
|
||||
uuid: user.uuid,
|
||||
username: user.username,
|
||||
display_name: user.display_name,
|
||||
avatar_file: user.avatar_file
|
||||
|
Reference in New Issue
Block a user