2017-08-07 01:05:10 +00:00
|
|
|
|
2018-03-05 20:49:36 +00:00
|
|
|
/* global WIKI */
|
2017-08-07 01:05:10 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2017-08-09 02:36:29 +00:00
|
|
|
Query: {
|
|
|
|
users(obj, args, context, info) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.findAll({ where: args })
|
2017-08-09 02:36:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
Mutation: {
|
|
|
|
createUser(obj, args) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.create(args)
|
2017-08-14 00:33:06 +00:00
|
|
|
},
|
|
|
|
deleteUser(obj, args) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.destroy({
|
2017-08-14 00:33:06 +00:00
|
|
|
where: {
|
|
|
|
id: args.id
|
|
|
|
},
|
|
|
|
limit: 1
|
|
|
|
})
|
2017-08-20 02:51:25 +00:00
|
|
|
},
|
2018-01-10 01:41:53 +00:00
|
|
|
login(obj, args, context) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.login(args, context).catch(err => {
|
2018-01-10 01:41:53 +00:00
|
|
|
return {
|
|
|
|
succeeded: false,
|
|
|
|
message: err.message
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
loginTFA(obj, args, context) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.loginTFA(args, context).catch(err => {
|
2018-01-10 01:41:53 +00:00
|
|
|
return {
|
|
|
|
succeeded: false,
|
|
|
|
message: err.message
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2017-08-20 02:51:25 +00:00
|
|
|
modifyUser(obj, args) {
|
2018-03-05 20:49:36 +00:00
|
|
|
return WIKI.db.User.update({
|
2017-08-20 02:51:25 +00:00
|
|
|
email: args.email,
|
|
|
|
name: args.name,
|
|
|
|
provider: args.provider,
|
|
|
|
providerId: args.providerId,
|
|
|
|
role: args.role
|
|
|
|
}, {
|
|
|
|
where: { id: args.id }
|
|
|
|
})
|
|
|
|
},
|
|
|
|
resetUserPassword(obj, args) {
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
setUserPassword(obj, args) {
|
|
|
|
return false
|
2017-08-09 02:36:29 +00:00
|
|
|
}
|
2017-08-07 01:05:10 +00:00
|
|
|
},
|
2017-08-09 02:36:29 +00:00
|
|
|
User: {
|
2017-08-07 01:05:10 +00:00
|
|
|
groups(usr) {
|
|
|
|
return usr.getGroups()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|