Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function logintoboggan_process_login($account, &$edit, $redirect = array()){
- global $user;
- $user = user_load($account->uid);
- //watchdog('login debug', json_encode($account));
- watchdog('login debug', json_encode($edit));
- //user_login_submit(array(), array('uid' => $account->uid));
- user_login_finalize($edit);
- // $user = user_load($account->uid);
- // $user->token = drupal_get_token('services'); // WE HAVE A TOKEN ALTHOUGH I DOUBT THIS WOULD WORK IN TERMS OF SESSION PERSISTANCE
- // user_login_finalize($edit);
- // module_invoke_all('hook_user_login');
- // module_invoke_all('tripchi_user_login');
- // module_invoke_all('logintoboggan_user_login');
- global $user;
- $username=$data['email'];
- $password=$data['pass'];
- if ($user->uid) {
- // user is already logged in
- return services_error(t('Already logged in as @user.', array('@user' => $user->name)), 406);
- }
- // Check if account is active.
- if (user_is_blocked($username)) {
- return services_error(t('The username %name has not been activated or is blocked.', array('%name' => $username)), 403);
- }
- // Emulate drupal native flood control: check for flood condition.
- $flood_state = array();
- if (variable_get('services_flood_control_enabled', TRUE)) {
- $flood_state = _user_resource_flood_control_precheck($username);
- }
- // Only authenticate if a flood condition was not detected.
- if (empty($flood_state['flood_control_triggered'])) {
- $uid = user_authenticate($username, $password);
- }
- else {
- $uid = FALSE;
- }
- // Emulate drupal native flood control: register flood event, and throw error
- // if a flood condition was previously detected
- if (variable_get('services_flood_control_enabled', TRUE)) {
- $flood_state['uid'] = $uid;
- _user_resource_flood_control_postcheck($flood_state);
- }
- if ($uid) {
- $user = user_load($uid);
- if ($user->uid) {
- user_login_finalize();
- $return = new stdClass();
- $return->sessid = session_id();
- $return->session_name = session_name();
- $return->token = drupal_get_token('services');
- $account = clone $user;
- services_remove_user_data($account);
- $return->user = $account;
- return $return;
- }
- }
- watchdog('user', 'Invalid login attempt for %username.', array('%username' => $username));
- return services_error(t('Wrong username or password.'), 401);
Add Comment
Please, Sign In to add comment