refactor: webpack fixes, missing auth icons, auth resolvers
This commit is contained in:
@@ -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 => {
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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!
|
||||
|
Reference in New Issue
Block a user