feat: jwt renew via graphql + users create/authorize UI

This commit is contained in:
Nicolas Giard
2018-10-13 23:22:42 -04:00
parent 3caa842d18
commit 14e34d4346
12 changed files with 742 additions and 376 deletions

View File

@@ -11,14 +11,14 @@ module.exports = {
UserQuery: {
async list(obj, args, context, info) {
return WIKI.models.users.query()
.select('id', 'email', 'name', 'providerKey', 'role', 'createdAt', 'updatedAt')
.select('id', 'email', 'name', 'providerKey', 'createdAt')
},
async search(obj, args, context, info) {
return WIKI.models.users.query()
.where('email', 'like', `%${args.query}%`)
.orWhere('name', 'like', `%${args.query}%`)
.limit(10)
.select('id', 'email', 'name', 'providerKey', 'role', 'createdAt', 'updatedAt')
.select('id', 'email', 'name', 'providerKey', 'createdAt')
},
async single(obj, args, context, info) {
let usr = await WIKI.models.users.query().findById(args.id)

View File

@@ -86,6 +86,7 @@ type UserMinimal {
name: String!
email: String!
providerKey: String!
createdAt: Date!
}
type User {

View File

@@ -22,7 +22,7 @@ module.exports = {
// Try headers, otherwise cookies for response
if (req.get('content-type') === 'application/json') {
res.headers('new-jwt', newToken.token)
res.set('new-jwt', newToken.token)
} else {
res.cookie('jwt', newToken.token, { expires: moment().add(365, 'days').toDate() })
}