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

Now 'signin redirect' option can be a function again #4482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion admin/server/routes/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ var templatePath = path.resolve(__dirname, '../templates/signin.html');

module.exports = function SigninRoute (req, res) {
var keystone = req.keystone;
var signinRedirect = keystone.get('signin redirect');
if (req.user && typeof signinRedirect === 'function') {
return signinRedirect(req.user, req, res);
}
var UserList = keystone.list(keystone.get('user model'));
var locals = {
adminPath: '/' + keystone.get('admin path'),
brand: keystone.get('brand'),
csrf: { header: {} },
logo: keystone.get('signin logo'),
redirect: keystone.get('signin redirect'),
redirect: signinRedirect,
user: req.user ? {
id: req.user.id,
name: UserList.getDocumentName(req.user) || '(no name)',
Expand Down
8 changes: 6 additions & 2 deletions docs/documentation/Configuration/Database-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,21 @@ A `href` string to use for the 'back to (site name)' link in the header of the A

A `href` to bounce visitors to when they fail the default auth check (e.g. not signed in). Defaults to `/keystone/signin`, only used when `auth` is set to `true`/

<h4 data-primitive-type="String"><code>signin redirect</code></h4>
<h4 data-primitive-type="String|Function"><code>signin redirect</code></h4>

A `href` to bounce visitors to after they successfully sign in via the built-in signin route. Defaults to `/keystone`.

If it's a function, it will be invoked with parameters `user`, `req` and `res` and should handle the redirect autonomously.

<h4 data-primitive-type="String"><code>signout url</code></h4>

A `href` for the signout link in the top right of the UI. Defaults to `/keystone/signout` if `auth` is set to `true`

<h4 data-primitive-type="String"><code>signout redirect</code></h4>
<h4 data-primitive-type="String|Function"><code>signout redirect</code></h4>

A `href` to bounce visitors to after they successfully sign out via the built-in sign out route. Defaults to `/keystone`

If it's a function, it will be invoked with parameters `req` and `res` and should handle the redirect autonomously.


For more information about setting up and using database models with Keystone, see the [database guide](/database/).