Browse Source

fix: redirect to previous path after login

pull/1452/head
NGPixel 4 years ago
parent
commit
ff5acba358
2 changed files with 12 additions and 1 deletions
  1. 8
      client/components/login.vue
  2. 5
      server/controllers/common.js

8
client/components/login.vue

@ -294,7 +294,13 @@ export default {
this.loaderTitle = this.$t('auth:loginSuccess') this.loaderTitle = this.$t('auth:loginSuccess')
Cookies.set('jwt', respObj.jwt, { expires: 365 }) Cookies.set('jwt', respObj.jwt, { expires: 365 })
_.delay(() => { _.delay(() => {
window.location.replace('/') // TEMPORARY - USE RETURNURL
const loginRedirect = Cookies.get('loginRedirect')
if (loginRedirect) {
Cookies.remove('loginRedirect')
window.location.replace(loginRedirect)
} else {
window.location.replace('/')
}
}, 1000) }, 1000)
} }
} else { } else {

5
server/controllers/common.js

@ -245,6 +245,11 @@ router.get('/*', async (req, res, next) => {
pageArgs.tags = _.get(page, 'tags', []) pageArgs.tags = _.get(page, 'tags', [])
if (!WIKI.auth.checkAccess(req.user, ['read:pages'], pageArgs)) { if (!WIKI.auth.checkAccess(req.user, ['read:pages'], pageArgs)) {
if (req.user.id === 2) {
res.cookie('loginRedirect', req.path, {
maxAge: 15 * 60 * 1000
})
}
if (pageArgs.path === 'home' && req.user.id === 2) { if (pageArgs.path === 'home' && req.user.id === 2) {
return res.redirect('/login') return res.redirect('/login')
} }

Loading…
Cancel
Save