mirror of
https://github.com/simple-login/app.git
synced 2025-09-07 07:04:18 +08:00
Set mailbox verified on pre-verified email change
This commit is contained in:
parent
accab2dd52
commit
869ea8bd7d
2 changed files with 23 additions and 1 deletions
|
@ -247,7 +247,7 @@ def verify_mailbox_code(user: User, mailbox_id: int, code: str) -> Mailbox:
|
|||
message=f"Verify mailbox {mailbox_id} ({mailbox.email})",
|
||||
)
|
||||
if Mailbox.get_by(email=mailbox.new_email, user_id=user.id):
|
||||
raise MailboxError("That addres is already in use")
|
||||
raise MailboxError("That address is already in use")
|
||||
|
||||
else:
|
||||
LOG.i(
|
||||
|
@ -354,6 +354,7 @@ def request_mailbox_email_change(
|
|||
if email_ownership_verified:
|
||||
mailbox.email = new_email
|
||||
mailbox.new_email = None
|
||||
mailbox.verified = True
|
||||
else:
|
||||
mailbox.new_email = new_email
|
||||
emit_user_audit_log(
|
||||
|
|
|
@ -641,3 +641,24 @@ def test_change_mailbox_verified_email_clears_pending_email(flask_client):
|
|||
assert out.activation is None
|
||||
assert out.mailbox.email == new_email
|
||||
assert out.mailbox.new_email is None
|
||||
|
||||
|
||||
def test_change_mailbox_verified_email_sets_mailbox_as_verified(flask_client):
|
||||
user = create_new_user()
|
||||
domain = f"{random_string(10)}.com"
|
||||
mail = f"mail_1@{domain}"
|
||||
mbox1 = Mailbox.create(
|
||||
email=mail,
|
||||
new_email=f"oldpending_{mail}",
|
||||
user_id=user.id,
|
||||
verified=False,
|
||||
flush=True,
|
||||
)
|
||||
new_email = f"new_{mail}"
|
||||
out = request_mailbox_email_change(
|
||||
user, mbox1, new_email, email_ownership_verified=True
|
||||
)
|
||||
assert out.activation is None
|
||||
assert out.mailbox.email == new_email
|
||||
assert out.mailbox.new_email is None
|
||||
assert out.mailbox.verified is True
|
||||
|
|
Loading…
Add table
Reference in a new issue