Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Added redirect back to personalize after told to login
Browse files Browse the repository at this point in the history
  • Loading branch information
craigspaeth committed May 10, 2017
1 parent f5442a8 commit e1a377b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/app/lifecycle.coffee
Expand Up @@ -120,7 +120,8 @@ crypto = require 'crypto'
next()

@ensureLoggedInOnAfterSignupPage = (req, res, next) ->
res.redirect opts.loginPagePath unless req.user?
toLogin = "#{opts.loginPagePath}?redirect-to=#{opts.afterSignupPagePath}"
res.redirect toLogin unless req.user?
next()

@onError = (err, req, res, next) ->
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "artsy-passport",
"version": "1.7.3",
"version": "1.7.4",
"description": "Wires up the common auth handlers for Artsy's [Ezel](ezeljs.com)-based apps using [passport](http://passportjs.org/).",
"keywords": [
"artsy",
Expand Down
6 changes: 4 additions & 2 deletions test/app/lifecycle.coffee
Expand Up @@ -18,7 +18,7 @@ describe 'lifecycle', ->
lifecycle.__set__ 'passport', @passport
lifecycle.__set__ 'opts', @opts =
loginPagePath: '/login'
afterSignupPagePath: '/signup'
afterSignupPagePath: '/personalize'
APP_URL: 'https://www.artsy.net'
ARTSY_URL: 'https://api.artsy.net'

Expand Down Expand Up @@ -154,7 +154,9 @@ describe 'lifecycle', ->

describe '#ensureLoggedInOnAfterSignupPage', ->

it 'redirects to the login page without a user'
it 'redirects to the login page, and back, without a user', ->
lifecycle.ensureLoggedInOnAfterSignupPage @req, @res, @next
@res.redirect.args[0][0].should.equal '/login?redirect-to=/personalize'

describe '#ssoAndRedirectBack', ->

Expand Down

0 comments on commit e1a377b

Please sign in to comment.