Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redirectTo function w/ blank to behave like blank redirectTo (fix) #183

merged 1 commit into from Feb 8, 2018


Copy link

flippidippi commented Dec 18, 2017

Fixing #169 pull request. I destroyed it.

Currently when redirectTo is a function and the function returns blank, hapi-auth-cookie stills tries to do the redirect instead of behaving like redirectTo: undefined. Fixing this will allow issues like #144 where you might want different behavior on an API call vs the browser.

This change will allow something like following code to redirect or not according to a header set

redirectTo (request) {
  const requestedWith = request.headers['x-requested-with'] && request.headers['x-requested-with'].toLowerCase()
  if (requestedWith && (requestedWith === 'ajax' || requestedWith === 'xmlhttprequest')) {
    return undefined
  } else {
    return '/login'

This comment has been minimized.

Copy link
Contributor Author

flippidippi commented Jan 19, 2018

@mrlannigan looks like there all no conflicts, can we get this merged soon?

@mrlannigan mrlannigan modified the milestones: 8.0.1, 8.1.0 Jan 20, 2018
@mrlannigan mrlannigan merged commit 3361ea6 into hapijs:master Feb 8, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link

mrlannigan commented Feb 8, 2018

Published with v8.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.