@nuxtjs/auth
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -5,2 +5,13 @@ # Change Log | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/nuxt-community/auth-module/compare/v3.0.1...v3.1.0) (2017-11-15) | ||
### Features | ||
* **store:** let LocalStorage to be optional ([#18](https://github.com/nuxt-community/auth-module/issues/18), [@epartipilo](https://github.com/epartipilo)) ([b4086a0](https://github.com/nuxt-community/auth-module/commit/b4086a0)) | ||
* improve token options ([2a2c4c2](https://github.com/nuxt-community/auth-module/commit/2a2c4c2)) | ||
<a name="3.0.1"></a> | ||
@@ -7,0 +18,0 @@ ## [3.0.1](https://github.com/nuxt-community/auth-module/compare/v3.0.0...v3.0.1) (2017-11-12) |
@@ -24,5 +24,7 @@ const { resolve } = require('path') | ||
enabled: true, | ||
type: 'Bearer', | ||
localStorage: true, | ||
name: 'token', | ||
cookieName: 'token', | ||
type: 'Bearer' | ||
cookie: true, | ||
cookieName: 'token' | ||
} | ||
@@ -29,0 +31,0 @@ } |
@@ -1,2 +0,2 @@ | ||
<% if (options.token && options.token.enabled && options.token.cookieName) { %> | ||
<% if (options.token.enabled && options.token.cookie) { %> | ||
import Cookie from 'cookie' | ||
@@ -10,3 +10,3 @@ import Cookies from 'js-cookie' | ||
state: () => ({ | ||
<% if (options.token && options.token.enabled) { %>token: null,<% } %> | ||
<% if (options.token.enabled) { %>token: null,<% } %> | ||
user: null | ||
@@ -17,3 +17,3 @@ }), | ||
loggedIn (state) { | ||
return Boolean(state.user<% if (options.token && options.token.enabled) { %> || state.token<% } %>) | ||
return Boolean(state.user<% if (options.token.enabled) { %> || state.token<% } %>) | ||
} | ||
@@ -28,3 +28,3 @@ }, | ||
<% if (options.token && options.token.enabled) { %> | ||
<% if (options.token.enabled) { %> | ||
// SET_TOKEN | ||
@@ -38,3 +38,3 @@ SET_TOKEN (state, token) { | ||
actions: { | ||
<% if (options.token && options.token.enabled) { %> | ||
<% if (options.token.enabled) { %> | ||
// Update token | ||
@@ -49,11 +49,13 @@ updateToken ({ commit }, token) { | ||
// Update localStorage | ||
if (process.browser && localStorage) { | ||
if (token) { | ||
localStorage.setItem('<%= options.token.name %>', token) | ||
} else { | ||
localStorage.removeItem('<%= options.token.name %>') | ||
<% if (options.token.localStorage) { %> | ||
if (process.browser && localStorage) { | ||
if (token) { | ||
localStorage.setItem('<%= options.token.name %>', token) | ||
} else { | ||
localStorage.removeItem('<%= options.token.name %>') | ||
} | ||
} | ||
} | ||
<% } %> | ||
<% if (options.token.cookieName) { %> | ||
<% if (options.token.cookie) { %> | ||
// Update cookies | ||
@@ -84,3 +86,3 @@ if (process.browser) { | ||
<% if (options.token && options.token.enabled) { %> | ||
<% if (options.token.enabled) { %> | ||
// Fetch Token | ||
@@ -90,2 +92,3 @@ fetchToken ({ dispatch }) { | ||
<% if (options.token.localStorage) { %> | ||
// Try to extract token from localStorage | ||
@@ -95,4 +98,5 @@ if (process.browser && localStorage) { | ||
} | ||
<% } %> | ||
<% if (options.token.cookieName) { %> | ||
<% if (options.token.cookie) { %> | ||
// Try to extract token from cookies | ||
@@ -115,3 +119,3 @@ if (!token) { | ||
commit('SET_USER', null) | ||
<% if (options.token && options.token.enabled) { %>dispatch('updateToken', null)<% } %> | ||
<% if (options.token.enabled) { %>dispatch('updateToken', null)<% } %> | ||
}, | ||
@@ -121,3 +125,3 @@ | ||
async fetch ({ getters, state, commit, dispatch }, { endpoint = '<%= options.user.endpoint %>' } = {}) { | ||
<% if (options.token && options.token.enabled) { %> | ||
<% if (options.token.enabled) { %> | ||
// Fetch and update latest token | ||
@@ -147,3 +151,3 @@ dispatch('fetchToken') | ||
<% if (options.token && options.token.enabled) { %> | ||
<% if (options.token.enabled) { %> | ||
dispatch('updateToken', data['<%= options.token.name %>']) | ||
@@ -150,0 +154,0 @@ <% } %> |
{ | ||
"name": "@nuxtjs/auth", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Authentication module for Nuxt.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -46,5 +46,7 @@ # Auth | ||
enabled: true, | ||
type: 'Bearer', | ||
localStorage: true, | ||
name: 'token', | ||
cookieName: 'token', | ||
type: 'Bearer' | ||
cookie: true, | ||
cookieName: 'token' | ||
} | ||
@@ -72,9 +74,11 @@ } | ||
* **enabled** - Get and use tokens for authentication. | ||
* **type** - Sets the token type of the authorization header. | ||
* **localStorage** - Decide whether to use or not the LocalStorage. | ||
* **name** - Set the token name in the local storage. | ||
* **cookieName** - Set the token name in Cookies. (Set to `null` to disable) | ||
* **type** - Sets the token type of the authorization header. | ||
* **cookie** - Decide whether to use or not the Cookies. | ||
* **cookieName** - Set the token name in Cookies. | ||
#### redirect | ||
* **notLoggedInRedirectTo** - Sets the redirect URL default of the users not logged in. Only when `auth` middleware is added to a page. | ||
* **loggedInRedirectTo** - Sets the redirect URL default of the users logged in. Only when `no-auth` middleware is added to a page. | ||
* **notLoggedIn** - Sets the redirect URL default of the users not logged in. Only when `auth` middleware is added to a page. | ||
* **loggedIn** - Sets the redirect URL default of the users logged in. Only when `no-auth` middleware is added to a page. | ||
@@ -81,0 +85,0 @@ ## Example usage |
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
15286
223
125