private function LingotekSession::login in Lingotek Translation 7.5
Same name and namespace in other branches
- 6 lingotek.session.inc \LingotekSession::login()
- 7.7 lingotek.session.inc \LingotekSession::login()
- 7.2 lingotek.session.inc \LingotekSession::login()
- 7.3 lingotek.session.inc \LingotekSession::login()
- 7.4 lingotek.session.inc \LingotekSession::login()
- 7.6 lingotek.session.inc \LingotekSession::login()
2 calls to LingotekSession::login()
File
- ./
lingotek.session.inc, line 239 - Handles api calls, logging in and logging out of LingoTek
Class
Code
private function login() {
if ($this->key == "") {
$params = array(
'loginId' => $this->login_id,
'password' => $this->password,
'community' => $this->community,
);
$login = 'login';
}
$error = 'unknown error';
$success = FALSE;
$response = array();
$data = $this
->request($login, $params, NULL, FALSE);
if (isset($data->data)) {
$response = json_decode($data->data);
if (isset($response->results) && $response->results == "success") {
$success = TRUE;
$error = '';
}
elseif (isset($response->results) && $response->results == "fail") {
$error = $response->error;
}
}
elseif (isset($data->error)) {
$error = $data->error;
}
if ($success) {
$this->headers = array(
"Cookie" => $data->headers['set-cookie'],
);
$this->logged_in = TRUE;
$this->last_login_msg = '';
}
else {
$this->logged_in = FALSE;
$this->last_login_msg = $error;
LingotekLog::error("Unable to log in", array(
'params' => $params,
'error' => $error,
'response' => json_encode($response),
), 'session');
}
}