app/assets/javascripts/ember-auth/ember-auth.js in ember-auth-rails-3.4.3 vs app/assets/javascripts/ember-auth/ember-auth.js in ember-auth-rails-3.5.0
- old
+ new
@@ -8,16 +8,22 @@
authToken: null,
currentUserId: null,
jqxhr: null,
prevRoute: null,
signIn: function(data) {
- var _this = this;
+ var async,
+ _this = this;
if (data == null) {
data = {};
}
+ async = data.async != null ? data.async : true;
+ if (data.async != null) {
+ delete data['async'];
+ }
return this.ajax(this.resolveUrl(Auth.Config.get('tokenCreateUrl')), 'POST', {
data: data,
+ async: async,
success: function(json, status, jqxhr) {
_this.set('authToken', json[Auth.Config.get('tokenKey')]);
_this.set('currentUserId', json[Auth.Config.get('idKey')]);
_this.set('jqxhr', jqxhr);
return _this.trigger('signInSuccess');
@@ -32,17 +38,23 @@
return _this.trigger('signInComplete');
}
});
},
signOut: function(data) {
- var _this = this;
+ var async,
+ _this = this;
if (data == null) {
data = {};
}
data[Auth.Config.get('tokenKey')] = this.get('authToken');
+ async = data.async != null ? data.async : true;
+ if (data.async != null) {
+ delete data['async'];
+ }
return this.ajax(this.resolveUrl(Auth.Config.get('tokenDestroyUrl')), 'DELETE', {
data: data,
+ async: async,
success: function(json, status, jqxhr) {
_this.set('authToken', null);
_this.set('currentUserId', null);
_this.set('jqxhr', jqxhr);
return _this.trigger('signOutSuccess');
@@ -112,11 +124,12 @@
smartSignOutRedirect: false,
signInRedirectFallbackRoute: 'index',
signOutRedirectFallbackRoute: 'index',
rememberMe: false,
rememberTokenKey: null,
- rememberPeriod: 14
+ rememberPeriod: 14,
+ rememberAutoRecall: true
});
Auth.Route = Em.Route.extend(Em.Evented, {
redirect: function() {
if (!Auth.get('authToken')) {
@@ -178,17 +191,23 @@
});
return Auth.on('signOutSuccess', function() {
return _this.forget();
});
},
- recall: function() {
+ recall: function(opts) {
var data, token;
+ if (opts == null) {
+ opts = {};
+ }
if (!Auth.Config.get('rememberMe')) {
return;
}
if (!Auth.get('authToken') && (token = $.cookie('ember-auth-remember-me'))) {
data = {};
+ if (opts.async != null) {
+ data['async'] = opts.async;
+ }
data[Auth.Config.get('rememberTokenKey')] = token;
return Auth.signIn(data);
}
},
remember: function() {
@@ -208,9 +227,20 @@
forget: function() {
if (!Auth.Config.get('rememberMe')) {
return;
}
return $.removeCookie('ember-auth-remember-me');
+ }
+ });
+
+ Auth.Route.reopen({
+ redirect: function() {
+ if (Auth.Config.get('rememberMe') && Auth.Config.get('rememberAutoRecall')) {
+ Auth.Module.RememberMe.recall({
+ async: false
+ });
+ }
+ return this._super();
}
});
}).call(this);