FIX: CSRF token retrieval bug

This commit is contained in:
Robin Ward 2013-12-03 15:30:33 -05:00
parent 50fe117d7c
commit c4394688de
2 changed files with 53 additions and 50 deletions

View File

@ -31,6 +31,8 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
return this.get('loggingIn') || this.blank('loginName') || this.blank('loginPassword');
}.property('loginName', 'loginPassword', 'loggingIn'),
actions: {
login: function() {
this.set('loggingIn', true);
@ -68,14 +70,6 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
return false;
},
authMessage: (function() {
if (this.blank('authenticate')) return "";
var method = Discourse.get('LoginMethod.all').findProperty("name", this.get("authenticate"));
if(method){
return method.get('message');
}
}).property('authenticate'),
externalLogin: function(loginMethod){
var name = loginMethod.get("name");
var customLogin = loginMethod.get("customLogin");
@ -92,8 +86,17 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
window.open(Discourse.getURL("/auth/" + name), "_blank",
"menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top);
}
}
},
authMessage: (function() {
if (this.blank('authenticate')) return "";
var method = Discourse.get('LoginMethod.all').findProperty("name", this.get("authenticate"));
if(method){
return method.get('message');
}
}).property('authenticate'),
authenticationComplete: function(options) {
if (options.requires_invite) {
this.flash(I18n.t('login.requires_invite'), 'success');

View File

@ -83,7 +83,7 @@ Discourse.Ajax = Em.Mixin.create({
return Ember.Deferred.promise(function(promise){
$.ajax(Discourse.getURL('/session/csrf'))
.success(function(result){
Discourse.csrfToken = result.csrf;
Discourse.Session.currentProp('csrfToken', result.csrf);
performAjax(promise);
});
});