-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implementation of the auth property settings in nuxt.config.js with default settings. * Solved (TODO Use set-cookie header for this..res - auth.store.js) * Bug fix resolution. * Creation of the local storage and cookie token name configuration parameter. * Documentation update. * Documentation update. * Documentation update and bug fix. * Documentation update. * Small improvements. * Ajustments. * Added middlewave redirect URL settings. * Bug fixes. * Bug fixes.
- Loading branch information
1 parent
fc6ae68
commit 5d870c2
Showing
4 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import middleware from './middleware' | ||
|
||
const options = <%= serialize(options) %> | ||
|
||
middleware.auth = function authMiddleware ({ store, redirect }) { | ||
// If user not logged in, redirect to /login | ||
if (!store.getters['auth/loggedIn']) { | ||
return redirect('/login') | ||
return redirect(options.notLoggedInRedirectTo) | ||
} | ||
} | ||
|
||
middleware['no-auth'] = function noAuthMiddleware ({ store, redirect }) { | ||
// If user is already logged in, redirect to / | ||
if (store.getters['auth/loggedIn']) { | ||
return redirect('/') | ||
return redirect(options.loggedInRedirectTo) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters