vue-jwt-auth
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -19,3 +19,3 @@ { | ||
}, | ||
"version": "0.5.0" | ||
"version": "0.6.0" | ||
} |
@@ -198,3 +198,15 @@ # vue-jwt-auth | ||
`**loginAs(data, redirectUrl, options)**` | ||
Login as another user. | ||
`**logoutAs(redirectUrl)**` | ||
Logout or other user. Will revert to previously logged in user. | ||
`**other()**` | ||
Check if we are currently logged in as another user. | ||
## Options | ||
@@ -201,0 +213,0 @@ |
@@ -119,3 +119,3 @@ module.exports = (function () { | ||
function _login(path, data, rememberMe, options) { | ||
function _login(path, data, rememberMe, redirectUrl, options) { | ||
options = options || {}; | ||
@@ -132,10 +132,10 @@ | ||
if (options.success) { | ||
options.success.call(this, resp); | ||
} | ||
this.fetch(function () { | ||
if (_this.getOption('loginRedirect') && _this.check()) { | ||
_this.$router.go(_this.getOption('loginRedirect')); | ||
if (options.success) { | ||
options.success.call(_this, resp); | ||
} | ||
if (redirectUrl && _this.check()) { | ||
_this.$router.go(redirectUrl); | ||
} | ||
}); | ||
@@ -151,3 +151,3 @@ }, { | ||
function _social(type, data, rememberMe, options) { | ||
function _social(type, data, rememberMe, redirectUrl, options) { | ||
var state, | ||
@@ -166,3 +166,3 @@ params = ''; | ||
data.state.rememberMe = rememberMe === true ? true : false; | ||
data.state.redirect = this.getOption('loginRedirect') || ''; | ||
data.state.redirect = redirectUrl || ''; | ||
@@ -217,4 +217,2 @@ data.appId = data.appId || this.getOption(type + 'AppId'); | ||
authRedirect : '/login', | ||
loginRedirect : '/account', | ||
logoutRedirect : '/', | ||
@@ -302,15 +300,15 @@ notFoundRedirect : '/404', | ||
login: function (data, rememberMe, options) { | ||
_login.call(this, this.getOption('loginUrl'), data, rememberMe, options); | ||
login: function (data, rememberMe, redirectUrl, options) { | ||
_login.call(this, this.getOption('loginUrl'), data, rememberMe, redirectUrl, options); | ||
}, | ||
facebook: function (data, rememberMe, options) { | ||
_social.call(this, 'facebook', data, rememberMe, options); | ||
facebook: function (data, rememberMe, redirectUrl, options) { | ||
_social.call(this, 'facebook', data, rememberMe, redirectUrl, options); | ||
}, | ||
google: function (data, rememberMe, options) { | ||
_social.call(this, 'google', data, rememberMe, options); | ||
google: function (data, rememberMe, redirectUrl, options) { | ||
_social.call(this, 'google', data, rememberMe, redirectUrl, options); | ||
}, | ||
logout: function() { | ||
logout: function(redirectUrl, force) { | ||
_removeRememberMeCookie.call(this); | ||
@@ -325,4 +323,4 @@ | ||
if (this.$route.auth && this.getOption('logoutRedirect')) { | ||
this.$router.go(this.getOption('logoutRedirect')); | ||
if (redirectUrl && (this.$route.auth || force)) { | ||
this.$router.go(redirectUrl); | ||
} | ||
@@ -382,3 +380,3 @@ }, | ||
loginAs: function(data, options) { | ||
loginAs: function(data, redirectUrl, options) { | ||
options = options || {}; | ||
@@ -391,10 +389,10 @@ | ||
if (options.success) { | ||
options.success.call(this, resp); | ||
} | ||
_fetch.call(this, function () { | ||
if (_this.getOption('loginRedirect') && _this.check()) { | ||
_this.$router.go(_this.getOption('loginRedirect')); | ||
if (options.success) { | ||
options.success.call(this, resp); | ||
} | ||
if (redirectUrl && _this.check()) { | ||
_this.$router.go(redirectUrl); | ||
} | ||
}); | ||
@@ -410,3 +408,3 @@ }, { | ||
logoutAs: function(options) { | ||
logoutAs: function(redirectUrl) { | ||
var _this = this; | ||
@@ -417,4 +415,4 @@ | ||
_fetch.call(this, function () { | ||
if (_this.$route.auth && _this.getOption('logoutRedirect')) { | ||
_this.$router.go(_this.getOption('logoutRedirect')); | ||
if (redirectUrl) { | ||
_this.$router.go(redirectUrl); | ||
} | ||
@@ -425,2 +423,4 @@ }); | ||
other: function() { | ||
this.data; // TODO: Strange thing, need this to make the check fire consistently ?? | ||
return localStorage.getItem('login-as-' + this.getOption('tokenName')); | ||
@@ -431,3 +431,3 @@ } | ||
return function install(Vue, options) { | ||
return function install(Vue, options, router) { | ||
var auth = new Vue(Auth); | ||
@@ -448,3 +448,3 @@ | ||
// // Setup before each route change check. | ||
Vue.router.beforeEach(function (transition) { | ||
(Vue.router || router).beforeEach(function (transition) { | ||
@@ -451,0 +451,0 @@ // Make sure to use $auth.fetch so context is loaded. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22327
345
0
336