2016-05-11 01:55:04 +05:30
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api\_pages;
|
|
|
|
|
|
|
|
use yii\codeception\BasePage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property \tests\codeception\api\FunctionalTester $actor
|
|
|
|
*/
|
|
|
|
class AuthenticationRoute extends BasePage {
|
|
|
|
|
2017-01-23 16:52:20 +05:30
|
|
|
/**
|
|
|
|
* @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-11 01:55:04 +05:30
|
|
|
$this->route = ['authentication/login'];
|
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) {
|
|
|
|
$params['token'] = $rememberMeOrToken;
|
2016-05-30 05:14:17 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
$this->actor->sendPOST($this->getUrl(), $params);
|
2016-05-11 01:55:04 +05:30
|
|
|
}
|
|
|
|
|
2016-07-17 22:08:04 +05:30
|
|
|
public function logout() {
|
|
|
|
$this->route = ['authentication/logout'];
|
|
|
|
$this->actor->sendPOST($this->getUrl());
|
|
|
|
}
|
|
|
|
|
2016-05-11 01:55:04 +05:30
|
|
|
public function forgotPassword($login = '') {
|
|
|
|
$this->route = ['authentication/forgot-password'];
|
|
|
|
$this->actor->sendPOST($this->getUrl(), [
|
|
|
|
'login' => $login,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-12 03:43:19 +05:30
|
|
|
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) {
|
|
|
|
$this->route = ['authentication/recover-password'];
|
|
|
|
$this->actor->sendPOST($this->getUrl(), [
|
|
|
|
'key' => $key,
|
|
|
|
'newPassword' => $newPassword,
|
|
|
|
'newRePassword' => $newRePassword,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-31 03:33:30 +05:30
|
|
|
public function refreshToken($refreshToken = null) {
|
|
|
|
$this->route = ['authentication/refresh-token'];
|
|
|
|
$this->actor->sendPOST($this->getUrl(), [
|
|
|
|
'refresh_token' => $refreshToken,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-05-11 01:55:04 +05:30
|
|
|
}
|