refactor: webpack fixes, missing auth icons, auth resolvers

This commit is contained in:
NGPixel
2018-03-10 00:58:04 -05:00
parent 69a0711d16
commit 16d3336cd0
25 changed files with 212 additions and 116 deletions

View File

@@ -29,6 +29,30 @@ module.exports = {
return prv
}
},
AuthenticationMutation: {
async login(obj, args, context) {
try {
let authResult = await WIKI.db.User.login(args, context)
return {
...authResult,
operation: graphHelper.generateSuccess('Login success')
}
} catch (err) {
return graphHelper.generateError(err)
}
},
async loginTFA(obj, args, context) {
try {
let authResult = await WIKI.db.User.loginTFA(args, context)
return {
...authResult,
operation: graphHelper.generateSuccess('TFA success')
}
} catch (err) {
return graphHelper.generateError(err)
}
}
},
AuthenticationProvider: {
icon (ap, args) {
return fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {

View File

@@ -19,22 +19,6 @@ 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

@@ -1,3 +1,7 @@
# ===============================================
# AUTHENTICATION
# ===============================================
extend type Query {
authentication: AuthenticationQuery
}
@@ -6,6 +10,10 @@ extend type Mutation {
authentication: AuthenticationMutation
}
# -----------------------------------------------
# QUERIES
# -----------------------------------------------
type AuthenticationQuery {
providers(
filter: String
@@ -13,7 +21,22 @@ type AuthenticationQuery {
): [AuthenticationProvider]
}
# -----------------------------------------------
# MUTATIONS
# -----------------------------------------------
type AuthenticationMutation {
login(
username: String!
password: String!
provider: String!
): AuthenticationLoginResponse
loginTFA(
loginToken: String!
securityCode: String!
): DefaultResponse
updateProvider(
provider: String!
isEnabled: Boolean!
@@ -21,6 +44,10 @@ type AuthenticationMutation {
): DefaultResponse
}
# -----------------------------------------------
# TYPES
# -----------------------------------------------
type AuthenticationProvider {
isEnabled: Boolean!
key: String!
@@ -30,3 +57,9 @@ type AuthenticationProvider {
icon: String
config: [KeyValuePair]
}
type AuthenticationLoginResponse {
operation: ResponseStatus
tfaRequired: Boolean
tfaLoginToken: String
}

View File

@@ -162,13 +162,6 @@ type OperationResult {
data: String
}
type LoginResult {
succeeded: Boolean!
message: String
tfaRequired: Boolean
tfaLoginToken: String
}
# Query (Read)
type Query {
comments(id: Int): [Comment]
@@ -265,17 +258,6 @@ type Mutation {
id: Int!
): OperationResult
login(
username: String!
password: String!
provider: String!
): LoginResult
loginTFA(
loginToken: String!
securityCode: String!
): OperationResult
modifyComment(
id: Int!
content: String!