feat: login + TFA authentication

This commit is contained in:
NGPixel
2018-01-09 20:41:53 -05:00
parent 85717bd369
commit cb0d86906f
14 changed files with 402 additions and 44 deletions

View File

@@ -19,6 +19,22 @@ module.exports = {
limit: 1
})
},
login(obj, args, context) {
return wiki.db.User.login(args, context).catch(err => {
return {
succeeded: false,
message: err.message
}
})
},
loginTFA(obj, args, context) {
return wiki.db.User.loginTFA(args, context).catch(err => {
return {
succeeded: false,
message: err.message
}
})
},
modifyUser(obj, args) {
return wiki.db.User.update({
email: args.email,

View File

@@ -148,8 +148,16 @@ type User implements Base {
}
type OperationResult {
succeded: Boolean!
succeeded: Boolean!
message: String
data: String
}
type LoginResult {
succeeded: Boolean!
message: String
tfaRequired: Boolean
tfaLoginToken: String
}
# Query (Read)
@@ -249,6 +257,17 @@ type Mutation {
id: Int!
): OperationResult
login(
username: String!
password: String!
provider: String!
): LoginResult
loginTFA(
loginToken: String!
securityCode: String!
): OperationResult
modifyComment(
id: Int!
content: String!