after successful registration user should be logged in

This commit is contained in:
Edin Dazdarevic
2015-03-03 22:19:41 +01:00
parent 9ebb4769af
commit 38de717da9
5 changed files with 26 additions and 18 deletions

View File

@@ -12,24 +12,28 @@ var UserActions = {
user: user
});
user.save(null, {
success: function() {
UserActions.registrationSuccess();
},
error: function(model, response, options) {
UserActions.registrationFailure(response);
}
});
superagent
.post(globals.ApiUrl + '/user')
.send(user)
.withCredentials()
.end(function(response){
if(response.ok) {
UserActions.registrationSuccess(response.body);
} else {
UserActions.registrationFailure(response.body);
}
});
},
registrationSuccess: function() {
registrationSuccess: function(user) {
AppDispatcher.handleAction({
actionType: UserConstants.REGISTRATION_SUCCESS
actionType: UserConstants.REGISTRATION_SUCCESS,
user: user
});
},
registrationFailure: function(error) {
AppDispatcher.handleAction({
actionType: UserConstants.REGISTRATION_FAILURE,
error: error
error: error
});
},
userLogout:function() {