fix: client login
This commit is contained in:
@@ -171,13 +171,13 @@ module.exports = class User extends Model {
|
||||
}
|
||||
|
||||
static async login (opts, context) {
|
||||
if (_.has(WIKI.config.auth.strategies, opts.provider)) {
|
||||
if (_.has(WIKI.auth.strategies, opts.strategy)) {
|
||||
_.set(context.req, 'body.email', opts.username)
|
||||
_.set(context.req, 'body.password', opts.password)
|
||||
|
||||
// Authenticate
|
||||
return new Promise((resolve, reject) => {
|
||||
WIKI.auth.passport.authenticate(opts.provider, async (err, user, info) => {
|
||||
WIKI.auth.passport.authenticate(opts.strategy, async (err, user, info) => {
|
||||
if (err) { return reject(err) }
|
||||
if (!user) { return reject(new WIKI.Error.AuthLoginFailed()) }
|
||||
|
||||
|
@@ -16,7 +16,7 @@ module.exports = {
|
||||
},
|
||||
AuthenticationQuery: {
|
||||
async strategies(obj, args, context, info) {
|
||||
let strategies = await WIKI.db.authentication.query().orderBy('title')
|
||||
let strategies = await WIKI.db.authentication.getEnabledStrategies()
|
||||
strategies = strategies.map(stg => ({
|
||||
...stg,
|
||||
config: _.transform(stg.config, (res, value, key) => {
|
||||
|
@@ -29,7 +29,7 @@ type AuthenticationMutation {
|
||||
login(
|
||||
username: String!
|
||||
password: String!
|
||||
provider: String!
|
||||
strategy: String!
|
||||
): AuthenticationLoginResponse
|
||||
|
||||
loginTFA(
|
||||
@@ -38,7 +38,7 @@ type AuthenticationMutation {
|
||||
): DefaultResponse
|
||||
|
||||
updateStrategy(
|
||||
provider: String!
|
||||
strategy: String!
|
||||
isEnabled: Boolean!
|
||||
config: [KeyValuePairInput]
|
||||
): DefaultResponse
|
||||
|
@@ -38,7 +38,7 @@ module.exports = async (job) => {
|
||||
|
||||
// -> Download locale strings
|
||||
|
||||
if (WIKI.config.langAutoUpdate) {
|
||||
if (WIKI.config.lang.autoUpdate) {
|
||||
const respStrings = await apollo({
|
||||
query: `query ($code: String!) {
|
||||
localization {
|
||||
|
@@ -7,7 +7,7 @@ module.exports = (req, res, next) => {
|
||||
// Is user authenticated ?
|
||||
|
||||
if (!req.isAuthenticated()) {
|
||||
if (WIKI.config.auth.public !== true) {
|
||||
if (WIKI.config.public !== true) {
|
||||
return res.redirect('/login')
|
||||
} else {
|
||||
// req.user = rights.guest
|
||||
|
Reference in New Issue
Block a user