mirror of
https://github.com/elyby/accounts.git
synced 2024-11-26 16:52:02 +05:30
Добавлена конвертация старых запросов к аккаунтам в новые
This commit is contained in:
parent
d2b7f28db6
commit
0198a3e010
@ -13,6 +13,18 @@ return [
|
||||
'DELETE /v1/accounts/<id:\d+>/ban' => 'accounts/default/pardon',
|
||||
'/v1/accounts/<id:\d+>/<action>' => 'accounts/default/<action>',
|
||||
|
||||
'GET /accounts/current' => 'accounts/default/get',
|
||||
'POST /accounts/change-username' => 'accounts/default/username',
|
||||
'POST /accounts/change-password' => 'accounts/default/password',
|
||||
'POST /accounts/change-email/initialize' => 'accounts/default/email-verification',
|
||||
'POST /accounts/change-email/submit-new-email' => 'accounts/default/new-email-verification',
|
||||
'POST /accounts/change-email/confirm-new-email' => 'accounts/default/email',
|
||||
'POST /accounts/accept-rules' => 'accounts/default/rules',
|
||||
'GET /two-factor-auth' => 'accounts/default/get-two-factor-auth-credentials',
|
||||
'POST /two-factor-auth' => 'accounts/default/enable-two-factor-auth',
|
||||
'DELETE /two-factor-auth' => 'accounts/default/disable-two-factor-auth',
|
||||
'POST /accounts/change-lang' => 'accounts/default/language',
|
||||
|
||||
'/account/v1/info' => 'identity-info/index',
|
||||
|
||||
'/minecraft/session/join' => 'session/session/join',
|
||||
|
@ -16,12 +16,23 @@ class DefaultController extends Controller {
|
||||
|
||||
public function behaviors(): array {
|
||||
$paramsCallback = function() {
|
||||
$id = Yii::$app->request->get('id');
|
||||
if ($id === null) {
|
||||
$identity = Yii::$app->user->getIdentity();
|
||||
if ($identity !== null) {
|
||||
$account = $identity->getAccount();
|
||||
if ($account !== null) {
|
||||
$id = $account->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'accountId' => Yii::$app->request->get('id'),
|
||||
'accountId' => $id,
|
||||
];
|
||||
};
|
||||
|
||||
return ArrayHelper::merge(Controller::behaviors(), [
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'access' => [
|
||||
'class' => AccessControl::class,
|
||||
'rules' => [
|
||||
@ -121,6 +132,18 @@ class DefaultController extends Controller {
|
||||
return (new TwoFactorAuthInfo($this->findAccount($id)))->getCredentials();
|
||||
}
|
||||
|
||||
public function bindActionParams($action, $params) {
|
||||
if (!isset($params['id'])) {
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$account = Yii::$app->user->getIdentity()->getAccount();
|
||||
if ($account !== null) {
|
||||
$params['id'] = $account->id;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::bindActionParams($action, $params);
|
||||
}
|
||||
|
||||
private function findAccount(int $id): Account {
|
||||
$account = Account::findOne($id);
|
||||
if ($account === null) {
|
||||
|
Loading…
Reference in New Issue
Block a user