@websanova/vue-auth
Advanced tools
Comparing version 2.15.2-beta to 2.16.0-beta
{ | ||
"dependencies": { | ||
"@websanova/vue-auth": "2.15.2-beta" | ||
"@websanova/vue-auth": "2.16.0-beta" | ||
}, | ||
@@ -5,0 +5,0 @@ |
{ | ||
"dependencies": { | ||
"@websanova/vue-auth": "2.15.2-beta", | ||
"@websanova/vue-auth": "2.16.0-beta", | ||
"axios": "0.16.2", | ||
@@ -5,0 +5,0 @@ "vue-axios": "2.0.2" |
{ | ||
"dependencies": { | ||
"nuxt": "1.0.0-rc3", | ||
"@websanova/vue-auth": "2.15.2-beta", | ||
"@websanova/vue-auth": "2.16.0-beta", | ||
"vue-resource": "1.3.4", | ||
@@ -6,0 +6,0 @@ "axios": "0.16.2", |
@@ -47,3 +47,3 @@ { | ||
"dependencies": { | ||
"@websanova/vue-auth": "2.15.2-beta", | ||
"@websanova/vue-auth": "2.16.0-beta", | ||
"axios": "^0.16.2", | ||
@@ -50,0 +50,0 @@ "compression": "^1.6.2", |
# Change Log | ||
### v2.15.x-beta | ||
* Add `tokenStore` array for setting storage preferences `(['localStorage', 'cookie'])`. | ||
* Fix removing `rememberMe` cookie on logout. | ||
* Fix register redirect to completely ignore login redirect. | ||
### v2.14.x-beta | ||
@@ -4,0 +10,0 @@ |
@@ -14,2 +14,6 @@ # Options | ||
### tokenStore: `['localStorage', 'cookie']` | ||
* Set storage method in order of importance and usage based on availability (from left to right). | ||
### rolesVar: `'roles'` | ||
@@ -16,0 +20,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"version": "2.15.2-beta", | ||
"version": "2.16.0-beta", | ||
@@ -20,0 +20,0 @@ "repository": { |
@@ -266,6 +266,6 @@ var __utils = require('./lib/utils.js'), | ||
function _logoutProcess(res, data) { | ||
__cookie.delete.call(this); | ||
__cookie.remove.call(this, 'rememberMe'); | ||
__token.delete.call(this, 'other'); | ||
__token.delete.call(this, 'default'); | ||
__token.remove.call(this, 'other'); | ||
__token.remove.call(this, 'default'); | ||
@@ -385,2 +385,3 @@ this.watch.authenticated = false; | ||
tokenName: 'auth_token', | ||
tokenStore: ['localStorage', 'cookie'], | ||
@@ -387,0 +388,0 @@ // Objects |
@@ -29,36 +29,36 @@ var __cookie = require('./cookie.js'); | ||
return { | ||
get: function (name) { | ||
name = tokenName.call(this, name); | ||
function isCookieSupported() { | ||
return true; | ||
} | ||
if (isLocalStorageSupported()) { | ||
return localStorage.getItem(name); | ||
function processToken(action, name, token) { | ||
var i, ii, | ||
args = [tokenName.call(this, name)]; | ||
if (token) { | ||
args.push(token); | ||
} | ||
for (i = 0, ii = this.options.tokenStore.length; i < ii; i++) { | ||
if (this.options.tokenStore[i] === 'localStorage' && isLocalStorageSupported()) { | ||
return localStorage[action + 'Item'](args[0], args[1]); | ||
} | ||
else { | ||
return __cookie.get.call(this, name); | ||
else if (this.options.tokenStore[i] === 'cookie' && isCookieSupported()) { | ||
return __cookie[action].apply(this, args); | ||
} | ||
} | ||
} | ||
return { | ||
get: function (name) { | ||
return processToken.call(this, 'get', name); | ||
}, | ||
set: function (name, token) { | ||
name = tokenName.call(this, name); | ||
if (token) { | ||
if (isLocalStorageSupported()) { | ||
localStorage.setItem(name, token); | ||
} | ||
else { | ||
__cookie.set.call(this, name, token); | ||
} | ||
} | ||
return processToken.call(this, 'set', name, token); | ||
}, | ||
delete: function (name) { | ||
name = tokenName.call(this, name); | ||
if (isLocalStorageSupported()) { | ||
localStorage.removeItem(name); | ||
} | ||
else { | ||
__cookie.delete.call(this, name); | ||
} | ||
remove: function (name) { | ||
return processToken.call(this, 'remove', name); | ||
}, | ||
@@ -65,0 +65,0 @@ |
754985
146
2391