feat: authentication module refactor + added CAS module
This commit is contained in:
35
server/modules/authentication/local/authentication.js
Normal file
35
server/modules/authentication/local/authentication.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/* global WIKI */
|
||||
|
||||
// ------------------------------------
|
||||
// Local Account
|
||||
// ------------------------------------
|
||||
|
||||
const LocalStrategy = require('passport-local').Strategy
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
passport.use('local',
|
||||
new LocalStrategy({
|
||||
usernameField: 'email',
|
||||
passwordField: 'password'
|
||||
}, (uEmail, uPassword, done) => {
|
||||
WIKI.db.users.query().findOne({
|
||||
email: uEmail,
|
||||
provider: 'local'
|
||||
}).then((user) => {
|
||||
if (user) {
|
||||
return user.verifyPassword(uPassword).then(() => {
|
||||
done(null, user)
|
||||
}).catch((err) => {
|
||||
done(err, null)
|
||||
})
|
||||
} else {
|
||||
done(new WIKI.Error.AuthLoginFailed(), null)
|
||||
}
|
||||
}).catch((err) => {
|
||||
done(err, null)
|
||||
})
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
5
server/modules/authentication/local/definition.yml
Normal file
5
server/modules/authentication/local/definition.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
key: local
|
||||
title: Local
|
||||
author: requarks.io
|
||||
useForm: true
|
||||
props: {}
|
Reference in New Issue
Block a user