2016-05-10 23:25:04 +03:00
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api\_pages;
|
|
|
|
|
|
|
|
class AuthenticationRoute extends BasePage {
|
|
|
|
|
2017-01-23 14:22:20 +03:00
|
|
|
/**
|
|
|
|
* @param string $login
|
|
|
|
* @param string $password
|
|
|
|
* @param string|bool|null $rememberMeOrToken
|
|
|
|
* @param bool $rememberMe
|
|
|
|
*/
|
|
|
|
public function login($login = '', $password = '', $rememberMeOrToken = null, $rememberMe = false) {
|
2016-05-30 02:44:17 +03:00
|
|
|
$params = [
|
2016-05-10 23:25:04 +03:00
|
|
|
'login' => $login,
|
|
|
|
'password' => $password,
|
2016-05-30 02:44:17 +03:00
|
|
|
];
|
|
|
|
|
2017-01-23 14:22:20 +03:00
|
|
|
if ((is_bool($rememberMeOrToken) && $rememberMeOrToken) || $rememberMe) {
|
2016-05-30 02:44:17 +03:00
|
|
|
$params['rememberMe'] = 1;
|
2017-01-23 14:22:20 +03:00
|
|
|
} elseif ($rememberMeOrToken !== null) {
|
2017-09-06 20:17:52 +03:00
|
|
|
$params['totp'] = $rememberMeOrToken;
|
2016-05-30 02:44:17 +03:00
|
|
|
}
|
|
|
|
|
2017-10-01 03:24:23 +03:00
|
|
|
$this->getActor()->sendPOST('/authentication/login', $params);
|
2016-05-10 23:25:04 +03:00
|
|
|
}
|
|
|
|
|
2016-07-17 19:38:04 +03:00
|
|
|
public function logout() {
|
2017-10-01 03:24:23 +03:00
|
|
|
$this->getActor()->sendPOST('/authentication/logout');
|
2016-07-17 19:38:04 +03:00
|
|
|
}
|
|
|
|
|
2017-01-23 23:50:13 +03:00
|
|
|
public function forgotPassword($login = null, $token = null) {
|
2017-10-01 03:24:23 +03:00
|
|
|
$this->getActor()->sendPOST('/authentication/forgot-password', [
|
2016-05-10 23:25:04 +03:00
|
|
|
'login' => $login,
|
2017-09-06 20:17:52 +03:00
|
|
|
'totp' => $token,
|
2016-05-10 23:25:04 +03:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-12 01:13:19 +03:00
|
|
|
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) {
|
2017-10-01 03:24:23 +03:00
|
|
|
$this->getActor()->sendPOST('/authentication/recover-password', [
|
2016-05-12 01:13:19 +03:00
|
|
|
'key' => $key,
|
|
|
|
'newPassword' => $newPassword,
|
|
|
|
'newRePassword' => $newRePassword,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-31 01:03:30 +03:00
|
|
|
public function refreshToken($refreshToken = null) {
|
2017-10-01 03:24:23 +03:00
|
|
|
$this->getActor()->sendPOST('/authentication/refresh-token', [
|
2016-05-31 01:03:30 +03:00
|
|
|
'refresh_token' => $refreshToken,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:25:04 +03:00
|
|
|
}
|