@nuxtjs/auth
Advanced tools
Comparing version 4.0.0-rc.2 to 4.0.0-rc.3
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="4.0.0-rc.3"></a> | ||
# [4.0.0-rc.3](https://github.com/nuxt-community/auth-module/compare/v4.0.0-rc.2...v4.0.0-rc.3) (2018-02-04) | ||
### Bug Fixes | ||
* fix scope checks during logout ([e2ebd97](https://github.com/nuxt-community/auth-module/commit/e2ebd97)) | ||
### Features | ||
* refactor init logic to $auth.init and improve error handling ([b58ca17](https://github.com/nuxt-community/auth-module/commit/b58ca17)) | ||
<a name="4.0.0-rc.2"></a> | ||
@@ -7,0 +22,0 @@ # [4.0.0-rc.2](https://github.com/nuxt-community/auth-module/compare/v4.0.0-rc.1...v4.0.0-rc.2) (2018-02-03) |
module.exports = { | ||
fetchUserOnLogin: true, | ||
resetOnError: true, | ||
resetOnError: false, | ||
rewriteRedirects: true, | ||
@@ -5,0 +5,0 @@ watchLoggedIn: true, |
@@ -14,3 +14,5 @@ import Cookies from 'js-cookie' | ||
this.options = options | ||
} | ||
init () { | ||
// Error listeners | ||
@@ -34,2 +36,8 @@ this._errorListeners = [] | ||
} | ||
// Sync token | ||
this.syncToken() | ||
// Fetch user if is not available | ||
return this.state.user ? Promise.resolve() : this.fetchUser() | ||
} | ||
@@ -208,8 +216,8 @@ | ||
return opts.propertyName ? getProp(data, opts.propertyName) : data | ||
} catch (err) { | ||
this._onError({ name, err, endpoint }) | ||
} catch (error) { | ||
// Call all error handlers | ||
this._onError(error, name, endpoint) | ||
if (process.browser) { | ||
throw err | ||
} | ||
// Throw error | ||
throw error | ||
} | ||
@@ -328,4 +336,4 @@ } | ||
hasScope (scope) { | ||
const userScopes = getProp(this.state.user, this.options.scopeKey) | ||
hasScope(scope) { | ||
const userScopes = this.state.user && getProp(this.state.user, this.options.scopeKey) | ||
@@ -332,0 +340,0 @@ if (!userScopes) { |
@@ -17,9 +17,6 @@ import './auth.middleware' | ||
// Sync token | ||
$auth.syncToken() | ||
// Fetch user if is not available | ||
if (!$auth.state.user) { | ||
return $auth.fetchUser() | ||
} | ||
// Initialize auth | ||
return $auth | ||
.init() | ||
.catch(process.server ? () => { } : console.error) | ||
} |
{ | ||
"name": "@nuxtjs/auth", | ||
"version": "4.0.0-rc.2", | ||
"version": "4.0.0-rc.3", | ||
"description": "Authentication module for Nuxt.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -121,3 +121,3 @@ <h1 align="center">🔑 Auth</h1> | ||
export default function({ $auth }) { | ||
$auth.onError(({ name, error }) => { | ||
$auth.onError((error, name, endpoint) => { | ||
console.error(name, error) | ||
@@ -254,3 +254,3 @@ }) | ||
* Default: `true` | ||
* Default: `false` | ||
@@ -257,0 +257,0 @@ If enabled, user will be automatically logged out if any error happens. (For example when token expired) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27207
397