You are here

function _services_sessions_authenticate_call in Services 6.3

Same name and namespace in other branches
  1. 7.3 services.module \_services_sessions_authenticate_call()

Authenticates a call using Drupal's built in sessions

Return value

void

1 string reference to '_services_sessions_authenticate_call'
services_services_authentication_info in ./services.module
Implementation of hook_services_authentication().

File

./services.module, line 337
Provides a generic but powerful API for web services.

Code

function _services_sessions_authenticate_call() {
  $arg = func_get_args();
  global $user;
  $original_user = services_get_server_info('original_user');

  //If the user is logged in already and the callback contains the string login

  //we need to set it to the original user so that the already logged in as @user message

  //is displayed
  if (strpos($arg[1]['callback'], 'login') !== FALSE) {
    if ($original_user->uid != 0) {
      $user = $original_user;
    }
  }

  //For every callback that has nothing to do with login we need to

  //set it to the original user so that they are no longer anonymous
  if (strpos($arg[1]['callback'], 'login') === FALSE) {

    // The account should be restored to the session's user.
    $user = $original_user;
  }
}