Guest User

Untitled

a guest
Apr 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. function logintoboggan_process_login($account, &$edit, $redirect = array()){
  2. global $user;
  3.  
  4. $user = user_load($account->uid);
  5.  
  6. //watchdog('login debug', json_encode($account));
  7. watchdog('login debug', json_encode($edit));
  8.  
  9. //user_login_submit(array(), array('uid' => $account->uid));
  10. user_login_finalize($edit);
  11.  
  12. // $user = user_load($account->uid);
  13. // $user->token = drupal_get_token('services'); // WE HAVE A TOKEN ALTHOUGH I DOUBT THIS WOULD WORK IN TERMS OF SESSION PERSISTANCE
  14. // user_login_finalize($edit);
  15. // module_invoke_all('hook_user_login');
  16. // module_invoke_all('tripchi_user_login');
  17. // module_invoke_all('logintoboggan_user_login');
  18.  
  19. global $user;
  20. $username=$data['email'];
  21. $password=$data['pass'];
  22. if ($user->uid) {
  23. // user is already logged in
  24. return services_error(t('Already logged in as @user.', array('@user' => $user->name)), 406);
  25. }
  26.  
  27. // Check if account is active.
  28. if (user_is_blocked($username)) {
  29. return services_error(t('The username %name has not been activated or is blocked.', array('%name' => $username)), 403);
  30. }
  31.  
  32. // Emulate drupal native flood control: check for flood condition.
  33. $flood_state = array();
  34. if (variable_get('services_flood_control_enabled', TRUE)) {
  35. $flood_state = _user_resource_flood_control_precheck($username);
  36. }
  37.  
  38. // Only authenticate if a flood condition was not detected.
  39. if (empty($flood_state['flood_control_triggered'])) {
  40. $uid = user_authenticate($username, $password);
  41. }
  42. else {
  43. $uid = FALSE;
  44. }
  45.  
  46. // Emulate drupal native flood control: register flood event, and throw error
  47. // if a flood condition was previously detected
  48. if (variable_get('services_flood_control_enabled', TRUE)) {
  49. $flood_state['uid'] = $uid;
  50. _user_resource_flood_control_postcheck($flood_state);
  51. }
  52.  
  53. if ($uid) {
  54. $user = user_load($uid);
  55. if ($user->uid) {
  56. user_login_finalize();
  57.  
  58. $return = new stdClass();
  59. $return->sessid = session_id();
  60. $return->session_name = session_name();
  61. $return->token = drupal_get_token('services');
  62. $account = clone $user;
  63. services_remove_user_data($account);
  64. $return->user = $account;
  65.  
  66. return $return;
  67. }
  68. }
  69. watchdog('user', 'Invalid login attempt for %username.', array('%username' => $username));
  70. return services_error(t('Wrong username or password.'), 401);
Add Comment
Please, Sign In to add comment