Guest User

Untitled

a guest
Jan 26th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $.when()
  2.                 .then(function() {
  3.                     var postData = { name: loginModel.formData.email, pass: loginModel.formData.password };
  4.                     return $.postJSON(controllerConfig.apiURL('user/login?_format=json'), postData);
  5.                  })
  6.                 .then(function(loginResponse) {
  7.                     $.clearAuthCookies();
  8.                     var cookieType = loginModel.useSessionCookie ? null : 365;
  9.                     var authorization = 'Basic ' + $.toBase64(loginModel.formData.email + ':' + loginModel.formData.password);
  10.                     $.cookie('X-CSRF-Token', loginResponse.csrf_token, cookieType);
  11.                     $.cookie('Authorization', authorization, cookieType);
  12.                 })
  13.                 .then(function() {
  14.                     return $.postJSON(controllerConfig.apiURL('apptitude/user?_format=json'));
  15.                 })
  16.                 .then(function(userResponse) {
  17.                     var ddo = new DrupalDataObject(userResponse);
  18.                     controllerConfig.userInfo.firstname = ddo.field('field_firstname');
  19.                     controllerConfig.userInfo.lastname = ddo.field('field_lastname');
  20.                     controllerConfig.userInfo.avatar = ddo.field('user_picture');
  21.                 })
  22.                 .then(function() {
  23.                     loginModel.firstname = controllerConfig.userInfo.firstname;
  24.                     $.renderView(views['login'], loginModel);
  25.                     loginModel.showSubPage('.js-subpage-success');
  26.                 })
  27.                 .always(function() { $.spinner.stop(); })
  28.                 .fail(function() { $.say(L('auth_loginFailed')); });
Advertisement
Add Comment
Please, Sign In to add comment