Auth: Fix bug in user registration

Due to fact that the automatically generated setEmail method is replaced by the method for a complete change of email address, which runs the save method. Because of this, in case of an error, the user will still be created. This commit renames the method for completely changing email address to avoid replacing the automatically generated method.
This commit is contained in:
Maxim Leshchenko 2022-05-07 15:00:25 +02:00
parent 63d6de7eec
commit aef369ac58
2 changed files with 3 additions and 3 deletions

View file

@ -877,7 +877,7 @@ class User extends RowModel
return true; return true;
} }
function setEmail(string $email): void function changeEmail(string $email): void
{ {
DatabaseConnection::i()->getContext()->table("ChandlerUsers") DatabaseConnection::i()->getContext()->table("ChandlerUsers")
->where("id", $this->getChandlerUser()->getId())->update([ ->where("id", $this->getChandlerUser()->getId())->update([

View file

@ -360,7 +360,7 @@ final class UserPresenter extends OpenVKPresenter
} }
try { try {
$user->setEmail($this->postParam("new_email")); $user->changeEmail($this->postParam("new_email"));
} catch(UniqueConstraintViolationException $ex) { } catch(UniqueConstraintViolationException $ex) {
$this->flashFail("err", tr("error"), tr("user_already_exists")); $this->flashFail("err", tr("error"), tr("user_already_exists"));
} }
@ -627,7 +627,7 @@ final class UserPresenter extends OpenVKPresenter
$request->delete(false); $request->delete(false);
try { try {
$request->getUser()->setEmail($request->getNewEmail()); $request->getUser()->changeEmail($request->getNewEmail());
} catch(UniqueConstraintViolationException $ex) { } catch(UniqueConstraintViolationException $ex) {
$this->flashFail("err", tr("error"), tr("user_already_exists")); $this->flashFail("err", tr("error"), tr("user_already_exists"));
} }