fix: bypass auth redirect cookie when set to homepage

pull/2543/head
NGPixel 4 years ago
parent 0fa5b9750d
commit fe890979af

@ -644,7 +644,10 @@ export default {
Cookies.set('jwt', respObj.jwt, { expires: 365 }) Cookies.set('jwt', respObj.jwt, { expires: 365 })
_.delay(() => { _.delay(() => {
const loginRedirect = Cookies.get('loginRedirect') const loginRedirect = Cookies.get('loginRedirect')
if (loginRedirect) { if (loginRedirect === '/' && respObj.redirect) {
Cookies.remove('loginRedirect')
window.location.replace(respObj.redirect)
} else if (loginRedirect) {
Cookies.remove('loginRedirect') Cookies.remove('loginRedirect')
window.location.replace(loginRedirect) window.location.replace(loginRedirect)
} else if (respObj.redirect) { } else if (respObj.redirect) {

@ -178,7 +178,7 @@ module.exports = class User extends Model {
const e = _.find(profile.emails, ['primary', true]) const e = _.find(profile.emails, ['primary', true])
primaryEmail = (e) ? e.value : _.first(profile.emails).value primaryEmail = (e) ? e.value : _.first(profile.emails).value
} else if (_.isArray(profile.email)) { } else if (_.isArray(profile.email)) {
primaryEmail = _.first(_.flattenDeep([profile.email])); primaryEmail = _.first(_.flattenDeep([profile.email]))
} else if (_.isString(profile.email) && profile.email.length > 5) { } else if (_.isString(profile.email) && profile.email.length > 5) {
primaryEmail = profile.email primaryEmail = profile.email
} else if (_.isString(profile.mail) && profile.mail.length > 5) { } else if (_.isString(profile.mail) && profile.mail.length > 5) {
@ -339,8 +339,14 @@ module.exports = class User extends Model {
user.groups = await user.$relatedQuery('groups').select('groups.id', 'permissions', 'redirectOnLogin') user.groups = await user.$relatedQuery('groups').select('groups.id', 'permissions', 'redirectOnLogin')
let redirect = '/' let redirect = '/'
if (user.groups && user.groups.length > 0) { if (user.groups && user.groups.length > 0) {
redirect = user.groups[0].redirectOnLogin for (const grp of user.groups) {
if (!_.isEmpty(grp.redirectOnLogin) && grp.redirectOnLogin !== '/') {
redirect = grp.redirectOnLogin
break
} }
}
}
console.info(redirect)
// Is 2FA required? // Is 2FA required?
if (!skipTFA) { if (!skipTFA) {

Loading…
Cancel
Save