2016-05-11 01:55:04 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\_pages;
|
2016-05-11 01:55:04 +05:30
|
|
|
|
|
|
|
class AuthenticationRoute extends BasePage {
|
|
|
|
|
2017-01-23 16:52:20 +05:30
|
|
|
/**
|
2024-12-02 15:40:55 +05:30
|
|
|
* @param string $login
|
|
|
|
* @param string $password
|
|
|
|
* @param bool|string|null $rememberMeOrToken
|
|
|
|
* @param bool $rememberMe
|
2017-01-23 16:52:20 +05:30
|
|
|
*/
|
2024-12-02 15:40:55 +05:30
|
|
|
public function login(string $login = '', string $password = '', bool|string|null $rememberMeOrToken = null, bool $rememberMe = false): void {
|
2016-05-30 05:14:17 +05:30
|
|
|
$params = [
|
2016-05-11 01:55:04 +05:30
|
|
|
'login' => $login,
|
|
|
|
'password' => $password,
|
2016-05-30 05:14:17 +05:30
|
|
|
];
|
|
|
|
|
2017-01-23 16:52:20 +05:30
|
|
|
if ((is_bool($rememberMeOrToken) && $rememberMeOrToken) || $rememberMe) {
|
2016-05-30 05:14:17 +05:30
|
|
|
$params['rememberMe'] = 1;
|
2017-01-23 16:52:20 +05:30
|
|
|
} elseif ($rememberMeOrToken !== null) {
|
2017-09-06 22:47:52 +05:30
|
|
|
$params['totp'] = $rememberMeOrToken;
|
2016-05-30 05:14:17 +05:30
|
|
|
}
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
$this->getActor()->sendPOST('/api/authentication/login', $params);
|
2016-05-11 01:55:04 +05:30
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function forgotPassword($login = null, $token = null): void {
|
2019-02-21 01:28:52 +05:30
|
|
|
$this->getActor()->sendPOST('/api/authentication/forgot-password', [
|
2016-05-11 01:55:04 +05:30
|
|
|
'login' => $login,
|
2017-09-06 22:47:52 +05:30
|
|
|
'totp' => $token,
|
2016-05-11 01:55:04 +05:30
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null): void {
|
2019-02-21 01:28:52 +05:30
|
|
|
$this->getActor()->sendPOST('/api/authentication/recover-password', [
|
2016-05-12 03:43:19 +05:30
|
|
|
'key' => $key,
|
|
|
|
'newPassword' => $newPassword,
|
|
|
|
'newRePassword' => $newRePassword,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function refreshToken($refreshToken = null): void {
|
2019-02-21 01:28:52 +05:30
|
|
|
$this->getActor()->sendPOST('/api/authentication/refresh-token', [
|
2016-05-31 03:33:30 +05:30
|
|
|
'refresh_token' => $refreshToken,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-11 01:55:04 +05:30
|
|
|
}
|