Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.when()
- .then(function() {
- var postData = { name: loginModel.formData.email, pass: loginModel.formData.password };
- return $.postJSON(controllerConfig.apiURL('user/login?_format=json'), postData);
- })
- .then(function(loginResponse) {
- $.clearAuthCookies();
- var cookieType = loginModel.useSessionCookie ? null : 365;
- var authorization = 'Basic ' + $.toBase64(loginModel.formData.email + ':' + loginModel.formData.password);
- $.cookie('X-CSRF-Token', loginResponse.csrf_token, cookieType);
- $.cookie('Authorization', authorization, cookieType);
- })
- .then(function() {
- return $.postJSON(controllerConfig.apiURL('apptitude/user?_format=json'));
- })
- .then(function(userResponse) {
- var ddo = new DrupalDataObject(userResponse);
- controllerConfig.userInfo.firstname = ddo.field('field_firstname');
- controllerConfig.userInfo.lastname = ddo.field('field_lastname');
- controllerConfig.userInfo.avatar = ddo.field('user_picture');
- })
- .then(function() {
- loginModel.firstname = controllerConfig.userInfo.firstname;
- $.renderView(views['login'], loginModel);
- loginModel.showSubPage('.js-subpage-success');
- })
- .always(function() { $.spinner.stop(); })
- .fail(function() { $.say(L('auth_loginFailed')); });
Advertisement
Add Comment
Please, Sign In to add comment