mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 05:11:34 +02:00
Redirect to login with a redirect back to the page we want if not logged in
This commit is contained in:
@@ -99,13 +99,17 @@ module.exports = AuthorizationMiddlewear =
|
||||
callback null, user_id
|
||||
|
||||
redirectToRestricted: (req, res, next) ->
|
||||
res.redirect "/restricted"
|
||||
res.redirect "/restricted?from=#{encodeURIComponent(req.url)}"
|
||||
|
||||
restricted : (req, res, next)->
|
||||
if req.session.user?
|
||||
res.render 'user/restricted',
|
||||
title:'restricted'
|
||||
else
|
||||
logger.log "user not logged in and trying to access #{req.url}, being redirected to login"
|
||||
res.redirect '/register'
|
||||
from = req.query.from
|
||||
logger.log {from: from}, "redirecting to login"
|
||||
redirect_to = "/login"
|
||||
if from?
|
||||
redirect_to += "?redir=#{encodeURIComponent(from)}"
|
||||
res.redirect redirect_to
|
||||
|
||||
Reference in New Issue
Block a user