mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: update hook
Hook payload updated to pass login strategy (if overridden, this value will be something other than 'local'), and explicitly pass error if the login failed.
This commit is contained in:
@@ -262,6 +262,7 @@ authenticationController.login = async (req, res, next) => {
|
|||||||
function continueLogin(strategy, req, res, next) {
|
function continueLogin(strategy, req, res, next) {
|
||||||
passport.authenticate(strategy, async (err, userData, info) => {
|
passport.authenticate(strategy, async (err, userData, info) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
plugins.hooks.fire('action:login.continue', { req, strategy, userData, error: err });
|
||||||
return helpers.noScriptErrors(req, res, err.message, 403);
|
return helpers.noScriptErrors(req, res, err.message, 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +272,8 @@ function continueLogin(strategy, req, res, next) {
|
|||||||
} else if (typeof info === 'object') {
|
} else if (typeof info === 'object') {
|
||||||
info = '[[error:invalid-username-or-password]]';
|
info = '[[error:invalid-username-or-password]]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins.hooks.fire('action:login.continue', { req, strategy, userData, error: new Error(info) });
|
||||||
return helpers.noScriptErrors(req, res, info, 403);
|
return helpers.noScriptErrors(req, res, info, 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +287,7 @@ function continueLogin(strategy, req, res, next) {
|
|||||||
req.session.cookie.expires = false;
|
req.session.cookie.expires = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.hooks.fire('action:login.continue', { req, userData });
|
plugins.hooks.fire('action:login.continue', { req, strategy, userData, error: null });
|
||||||
|
|
||||||
if (userData.passwordExpiry && userData.passwordExpiry < Date.now()) {
|
if (userData.passwordExpiry && userData.passwordExpiry < Date.now()) {
|
||||||
winston.verbose(`[auth] Triggering password reset for uid ${userData.uid} due to password policy`);
|
winston.verbose(`[auth] Triggering password reset for uid ${userData.uid} due to password policy`);
|
||||||
|
|||||||
Reference in New Issue
Block a user