mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Объединены сущности для авторизации посредством JWT токенов и токенов, выданных через oAuth2.
Все действия, связанные с аккаунтами, теперь вызываются через url `/api/v1/accounts/<id>/<action>`. Добавлена вменяемая система разграничения прав на основе RBAC. Теперь oAuth2 токены генерируются как случайная строка в 40 символов длинной, а не UUID. Исправлен баг с неправильным временем жизни токена в ответе успешного запроса аутентификации. Теперь все unit тесты можно успешно прогнать без наличия интернета.
This commit is contained in:
@@ -8,13 +8,13 @@ use yii\codeception\BasePage;
|
||||
*/
|
||||
class AccountsRoute extends BasePage {
|
||||
|
||||
public function current() {
|
||||
$this->route = ['accounts/current'];
|
||||
public function get(int $accountId) {
|
||||
$this->route = "/v1/accounts/{$accountId}";
|
||||
$this->actor->sendGET($this->getUrl());
|
||||
}
|
||||
|
||||
public function changePassword($currentPassword = null, $newPassword = null, $newRePassword = null) {
|
||||
$this->route = ['accounts/change-password'];
|
||||
public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) {
|
||||
$this->route = "/v1/accounts/{$accountId}/password";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'password' => $currentPassword,
|
||||
'newPassword' => $newPassword,
|
||||
@@ -22,46 +22,56 @@ class AccountsRoute extends BasePage {
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeUsername($currentPassword = null, $newUsername = null) {
|
||||
$this->route = ['accounts/change-username'];
|
||||
public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) {
|
||||
$this->route = "/v1/accounts/{$accountId}/username";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'password' => $currentPassword,
|
||||
'username' => $newUsername,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeEmailInitialize($password = '') {
|
||||
$this->route = ['accounts/change-email-initialize'];
|
||||
public function changeEmailInitialize(int $accountId, $password = '') {
|
||||
$this->route = "/v1/accounts/{$accountId}/email-verification";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'password' => $password,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeEmailSubmitNewEmail($key = null, $email = null) {
|
||||
$this->route = ['accounts/change-email-submit-new-email'];
|
||||
public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) {
|
||||
$this->route = "/v1/accounts/{$accountId}/new-email-verification";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'key' => $key,
|
||||
'email' => $email,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeEmailConfirmNewEmail($key = null) {
|
||||
$this->route = ['accounts/change-email-confirm-new-email'];
|
||||
public function changeEmail(int $accountId, $key = null) {
|
||||
$this->route = "/v1/accounts/{$accountId}/email";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'key' => $key,
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeLang($lang = null) {
|
||||
$this->route = ['accounts/change-lang'];
|
||||
public function changeLanguage(int $accountId, $lang = null) {
|
||||
$this->route = "/v1/accounts/{$accountId}/language";
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'lang' => $lang,
|
||||
]);
|
||||
}
|
||||
|
||||
public function acceptRules() {
|
||||
$this->route = ['accounts/accept-rules'];
|
||||
public function acceptRules(int $accountId) {
|
||||
$this->route = "/v1/accounts/{$accountId}/rules";
|
||||
$this->actor->sendPOST($this->getUrl());
|
||||
}
|
||||
|
||||
public function ban(int $accountId) {
|
||||
$this->route = "/v1/accounts/{$accountId}/ban";
|
||||
$this->actor->sendPOST($this->getUrl());
|
||||
}
|
||||
|
||||
public function pardon($accountId) {
|
||||
$this->route = "/v1/accounts/{$accountId}/ban";
|
||||
$this->actor->sendDELETE($this->getUrl());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,16 +8,6 @@ use yii\codeception\BasePage;
|
||||
*/
|
||||
class InternalRoute extends BasePage {
|
||||
|
||||
public function ban($accountId) {
|
||||
$this->route = '/internal/accounts/' . $accountId . '/ban';
|
||||
$this->actor->sendPOST($this->getUrl());
|
||||
}
|
||||
|
||||
public function pardon($accountId) {
|
||||
$this->route = '/internal/accounts/' . $accountId . '/ban';
|
||||
$this->actor->sendDELETE($this->getUrl());
|
||||
}
|
||||
|
||||
public function info(string $param, string $value) {
|
||||
$this->route = '/internal/accounts/info';
|
||||
$this->actor->sendGET($this->getUrl(), [$param => $value]);
|
||||
|
||||
@@ -8,24 +8,29 @@ use yii\codeception\BasePage;
|
||||
*/
|
||||
class TwoFactorAuthRoute extends BasePage {
|
||||
|
||||
public $route = '/two-factor-auth';
|
||||
|
||||
public function credentials() {
|
||||
public function credentials(int $accountId) {
|
||||
$this->setRoute($accountId);
|
||||
$this->actor->sendGET($this->getUrl());
|
||||
}
|
||||
|
||||
public function enable($totp = null, $password = null) {
|
||||
public function enable(int $accountId, $totp = null, $password = null) {
|
||||
$this->setRoute($accountId);
|
||||
$this->actor->sendPOST($this->getUrl(), [
|
||||
'totp' => $totp,
|
||||
'password' => $password,
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable($totp = null, $password = null) {
|
||||
public function disable(int $accountId, $totp = null, $password = null) {
|
||||
$this->setRoute($accountId);
|
||||
$this->actor->sendDELETE($this->getUrl(), [
|
||||
'totp' => $totp,
|
||||
'password' => $password,
|
||||
]);
|
||||
}
|
||||
|
||||
private function setRoute(int $accountId) {
|
||||
$this->route = "/v1/accounts/{$accountId}/two-factor-auth";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user