wikijs-fork/server/graph/resolvers/user.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-08-07 01:05:10 +00:00
/* global WIKI */
2017-08-07 01:05:10 +00:00
module.exports = {
Query: {
users(obj, args, context, info) {
return WIKI.db.User.findAll({ where: args })
}
},
Mutation: {
createUser(obj, args) {
return WIKI.db.User.create(args)
},
deleteUser(obj, args) {
return WIKI.db.User.destroy({
where: {
id: args.id
},
limit: 1
})
},
2018-01-10 01:41:53 +00:00
login(obj, args, context) {
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) {
return WIKI.db.User.loginTFA(args, context).catch(err => {
2018-01-10 01:41:53 +00:00
return {
succeeded: false,
message: err.message
}
})
},
modifyUser(obj, args) {
return WIKI.db.User.update({
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-07 01:05:10 +00:00
},
User: {
2017-08-07 01:05:10 +00:00
groups(usr) {
return usr.getGroups()
}
}
}