mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлена конвертация старых запросов к аккаунтам в новые
This commit is contained in:
@@ -13,6 +13,18 @@ return [
|
|||||||
'DELETE /v1/accounts/<id:\d+>/ban' => 'accounts/default/pardon',
|
'DELETE /v1/accounts/<id:\d+>/ban' => 'accounts/default/pardon',
|
||||||
'/v1/accounts/<id:\d+>/<action>' => 'accounts/default/<action>',
|
'/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',
|
'/account/v1/info' => 'identity-info/index',
|
||||||
|
|
||||||
'/minecraft/session/join' => 'session/session/join',
|
'/minecraft/session/join' => 'session/session/join',
|
||||||
|
@@ -16,12 +16,23 @@ class DefaultController extends Controller {
|
|||||||
|
|
||||||
public function behaviors(): array {
|
public function behaviors(): array {
|
||||||
$paramsCallback = function() {
|
$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 [
|
return [
|
||||||
'accountId' => Yii::$app->request->get('id'),
|
'accountId' => $id,
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
return ArrayHelper::merge(Controller::behaviors(), [
|
return ArrayHelper::merge(parent::behaviors(), [
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::class,
|
'class' => AccessControl::class,
|
||||||
'rules' => [
|
'rules' => [
|
||||||
@@ -121,6 +132,18 @@ class DefaultController extends Controller {
|
|||||||
return (new TwoFactorAuthInfo($this->findAccount($id)))->getCredentials();
|
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 {
|
private function findAccount(int $id): Account {
|
||||||
$account = Account::findOne($id);
|
$account = Account::findOne($id);
|
||||||
if ($account === null) {
|
if ($account === null) {
|
||||||
|
Reference in New Issue
Block a user