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

'signin redirect' only takes a string as second parameter #4449

Open
hreimer opened this issue Sep 27, 2017 · 3 comments
Open

'signin redirect' only takes a string as second parameter #4449

hreimer opened this issue Sep 27, 2017 · 3 comments

Comments

@hreimer
Copy link

hreimer commented Sep 27, 2017

Expected behavior

Following this closed issue #1489 I was expecting both versions to work:

keystone.set('signin redirect', '/whatever/url/you/want');
// -or-
keystone.set('signin redirect', function(user, req, res){
  var url = (user.isAdmin) ? '/keystone' : '/whatever/url/you/want';
  res.redirect(url);
});

Upon inspecting keystone/admin/server/routes/signin.js:14 and keystone/admin/server/routes/signout.js:8 I assumed, the signin redirect should also be able to take a function just as the signout redirect does (the latter does work with a string and a function)

Actual/Current behavior

Only the first version (setting the redirect route to a fixed string) worked, when setting it to a function it is simply never executed.

Steps to reproduce the actual/current behavior

Open keystone.js and insert one of the parts of the above code before keystone.start(), start keystone and try to sign into the Admin UI.

The referenced issue is over 2 years old nevertheless so if the current state is the desired behaviour this issue can be closed, although it would be a nice addition.

Environment

Software Version
Keystone 4.0.0-beta.5
Node 6.9.5
@vamshi9
Copy link

vamshi9 commented Oct 21, 2017

@hreimer That would be an ideal solution! I'm thinking the issue is with the params getting passed to the callback function. Is it so?

@frapan
Copy link

frapan commented Oct 25, 2017

@hreimer I've got the same problem and I think you explained it very well.
Looking at the singin.js source code you provided I've found out how to solve this problem and make Keystone 4 work the same way Keystone 0.3 worked.
It's a simple addition to that file.
I will provide a pull request as soon as possible, hopefully tomorrow.
Note: issue #4469 is a clone of this issue.

@hreimer
Copy link
Author

hreimer commented Oct 26, 2017

hey @vamshi9 & @frapan thanks for confirming my issue and providing a PR for that, I didn't have time to do it myself and only fixed it locally for test purposes - now we only have to wait for one of the maintainer to merge that PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants