You are here

public function ServicesClientConnectionSessionAuth::login in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_client_connection/plugins/ServicesClientConnectionSessionAuth.inc \ServicesClientConnectionSessionAuth::login()

Implements login().

Overrides ServicesClientConnectionAuth::login

File

services_client_connection/plugins/ServicesClientConnectionSessionAuth.inc, line 68
Session authentication for 3.x version

Class

ServicesClientConnectionSessionAuth
@file Session authentication for 3.x version

Code

public function login() {
  $response = $this->client
    ->action('user', 'login', array(
    'username' => $this->config['username'],
    'password' => $this->config['password'],
  ));
  $this->sessid = $response['sessid'];
  $this->session_name = $response['session_name'];
  $this->user = $response['user'];

  // If configured to use CSRF token retrieve token first.
  if (!empty($this->config['token'])) {
    $response = $this->client
      ->action('user', 'token');
    if (!empty($response['token'])) {
      $this->csrf_token = $response['token'];
    }
  }
}