Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Fix #154 - redirect /login to / when already logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Feb 5, 2016
1 parent 17eeb3f commit 783b63b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/controllers/routes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ module.exports =
'routes/reset*': get: index.resetRoutes

'register':
get: auth.registerIndex
get: [utils.isNotAuthenticated, auth.registerIndex]
post: [auth.register, utils.authenticate]

'login':
get: auth.loginIndex
get: [utils.isNotAuthenticated, auth.loginIndex]
post: utils.authenticate
'login/forgot': post: auth.forgotPassword
'logout': get: [utils.isAuthenticated, auth.logout]
Expand Down
6 changes: 5 additions & 1 deletion server/middlewares/authentication.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ module.exports.isAuthenticated = (req, res, next) ->
url += "&#{qs.stringify req.query}" if req.query.length
res.redirect url


module.exports.isNotAuthenticated = (req, res, next) ->
if req.isAuthenticated()
res.redirect '/'
else
next()

0 comments on commit 783b63b

Please sign in to comment.