|
@@ -121,7 +121,7 @@ module.exports = function(crowi, app) {
|
|
|
await crowi.activityService.createActivity(parameters);
|
|
await crowi.activityService.createActivity(parameters);
|
|
|
|
|
|
|
|
if (isExternalAccount) {
|
|
if (isExternalAccount) {
|
|
|
- return res.redirect('/');
|
|
|
|
|
|
|
+ return res.redirect(res.locals.redirectTo ?? '/');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// check for redirection to '/invited'
|
|
// check for redirection to '/invited'
|
|
@@ -133,6 +133,17 @@ module.exports = function(crowi, app) {
|
|
|
return res.apiv3({ redirectTo, userStatus: req.user.status });
|
|
return res.apiv3({ redirectTo, userStatus: req.user.status });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const injectRedirectTo = (req, res, next) => {
|
|
|
|
|
+
|
|
|
|
|
+ // Move "req.session.redirectTo" to "res.locals.redirectTo" because the session is regenerated when req.login() is called
|
|
|
|
|
+ const redirectTo = req.session.redirectTo;
|
|
|
|
|
+ if (redirectTo != null) {
|
|
|
|
|
+ res.locals.redirectTo = redirectTo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ next();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const isEnableLoginWithLocalOrLdap = (req, res, next) => {
|
|
const isEnableLoginWithLocalOrLdap = (req, res, next) => {
|
|
|
if (!passportService.isLocalStrategySetup && !passportService.isLdapStrategySetup) {
|
|
if (!passportService.isLocalStrategySetup && !passportService.isLdapStrategySetup) {
|
|
|
logger.error('LocalStrategy and LdapStrategy has not been set up');
|
|
logger.error('LocalStrategy and LdapStrategy has not been set up');
|
|
@@ -595,6 +606,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
cannotLoginErrorHadnler,
|
|
cannotLoginErrorHadnler,
|
|
|
|
|
+ injectRedirectTo,
|
|
|
isEnableLoginWithLocalOrLdap,
|
|
isEnableLoginWithLocalOrLdap,
|
|
|
loginFailure,
|
|
loginFailure,
|
|
|
loginFailureForExternalAccount,
|
|
loginFailureForExternalAccount,
|