Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need to use user_id in recovery and settings controller #929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions controllers/RecoveryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ public function actionRequest()
* @return string
* @throws \yii\web\NotFoundHttpException
*/
public function actionReset($id, $code)
public function actionReset($code)
{
if (!$this->module->enablePasswordRecovery) {
throw new NotFoundHttpException();
}

/** @var Token $token */
$token = $this->finder->findToken(['user_id' => $id, 'code' => $code, 'type' => Token::TYPE_RECOVERY])->one();
if (empty($token) || ! $token instanceof Token) {
$token = $this->finder->findToken(['code' => $code, 'type' => Token::TYPE_RECOVERY])->one();
if (empty($token) || ! $token instanceof Token) {
throw new NotFoundHttpException();
}
$event = $this->getResetPasswordEvent($token);
Expand Down
8 changes: 6 additions & 2 deletions controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,13 @@ public function actionAccount()
* @return string
* @throws \yii\web\HttpException
*/
public function actionConfirm($id, $code)
public function actionConfirm($code)
{
$user = $this->finder->findUserById($id);

$token_user = $this->finder->findToken(['code' => $code])->one();
$user_id = $token_user->user_id;

$user = $this->finder->findUserById($user_id);

if ($user === null || $this->module->emailChangeStrategy == Module::STRATEGY_INSECURE) {
throw new NotFoundHttpException();
Expand Down
2 changes: 1 addition & 1 deletion models/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getUrl()
throw new \RuntimeException();
}

return Url::to([$route, 'id' => $this->user_id, 'code' => $this->code], true);
return Url::to([$route, 'code' => $this->code], true);
}

/**
Expand Down