1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Add example and documentation around triggering login modal #234

This commit is contained in:
Paul Nelson 2018-01-20 13:35:54 -06:00 committed by Ivar Conradi Østhus
parent c544f81fba
commit 2491dfd7be
2 changed files with 14 additions and 1 deletions

View File

@ -22,6 +22,16 @@ unleash.start({
});
```
Additionally, you can trigger the admin interfact to prompt the user to sign in by configuring your middleware to return a `401` status on
protected routes. The response body must contain a `message` and a `path` used to redirect the user to the proper login route.
```json
{
"message": "You must be logged in to use Unlseash",
"path": "/custom/login"
}
```
Examples on custom authentication hooks:
- [google-auth-hook.js](https://github.com/Unleash/unleash/blob/master/examples/google-auth-hook.js)
- [basic-auth-hook.js](https://github.com/Unleash/unleash/blob/master/examples/basic-auth-hook.js)

View File

@ -16,7 +16,10 @@ function basicAuthentication(app) {
return res
.status('401')
.set({ 'WWW-Authenticate': 'Basic realm="example"' })
.end('access denied');
.send({
message: 'You must be authenticated to use Unleash',
path: '/custom/login',
});
}
});