question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect non-administrators to custom route

See original GitHub issue

Hello. I’d like to redirect users who do not have access to Keystone to a custom route rather than display the login page with the message “You’re already signed in”. Is this possible and if so, what would you recommend? I’ve already tried something like…

app.get('/keystone/signin', function(req, res, next){
    //if user is logged in but does not have Keystone access, redirect
    next();
});

but I suspect the internals of keystone.start() is preventing this from taking effect

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
creynderscommented, Jun 23, 2015

@offmadisonave easiest would be to use signin redirect: it’s an option you can set as a string or a function which allows you to determine where the user is redirected to when authentication succeeds:

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);
});

There’s other approaches too, but I think this one should be most suited.

0reactions
mubarakshowcommented, Oct 23, 2018

In Keystone 4 it seems only keystone.set('signin redirect', '/whatever/url/you/want'); works, not returning a function.

Should this be included in the signin config in the node_modules/keystone ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to redirect Admin to a specific page and users to another
Route ::get('/', 'HomeController@redirectUser');. Additionally create your own routes which you want to redirect to. Route::group(['middleware' ...
Read more >
How to create a custom WordPress login redirect
Today we look into how to use WordPress login redirect tools for custom login pages. We investigate how and why we should create...
Read more >
Magento 2 Why my admin route always redirect to the ...
I have a custom module with a backend menu ...
Read more >
Forward Gmail emails to another user - Google Support
Forward messages with address maps. As an admin, you can set up address maps to redirect incoming messages to other people or accounts....
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
Routing. Basic Routing. Redirect Routes; View Routes; The Route List ... You may customize the status code using the optional third parameter:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found