mirror of
https://github.com/simple-login/app.git
synced 2025-02-20 22:02:54 +08:00
fix showing unverified mailbox when creating new alias
This commit is contained in:
parent
d5977be7d7
commit
a9a5f145aa
3 changed files with 18 additions and 1 deletions
|
@ -44,7 +44,7 @@ def custom_alias():
|
|||
)
|
||||
|
||||
mailboxes = [current_user.email]
|
||||
for mailbox in Mailbox.query.filter_by(user_id=current_user.id):
|
||||
for mailbox in Mailbox.query.filter_by(user_id=current_user.id, verified=True):
|
||||
mailboxes.append(mailbox.email)
|
||||
|
||||
if request.method == "POST":
|
||||
|
|
|
@ -186,6 +186,7 @@ def fake_data():
|
|||
db.session.commit()
|
||||
|
||||
Mailbox.create(user_id=user.id, email="ab@cd.ef", verified=True)
|
||||
Mailbox.create(user_id=user.id, email="xy@zt.com", verified=False)
|
||||
db.session.commit()
|
||||
|
||||
DeletedAlias.create(user_id=user.id, email="d1@ab.cd")
|
||||
|
|
|
@ -2,6 +2,7 @@ from flask import url_for
|
|||
|
||||
from app.config import EMAIL_DOMAIN
|
||||
from app.extensions import db
|
||||
from app.models import Mailbox
|
||||
from app.utils import random_word
|
||||
from tests.utils import login
|
||||
|
||||
|
@ -24,3 +25,18 @@ def test_add_alias_success(flask_client):
|
|||
|
||||
assert r.status_code == 200
|
||||
assert f"Alias prefix.{word}@{EMAIL_DOMAIN} has been created" in str(r.data)
|
||||
|
||||
|
||||
def test_not_show_unverified_mailbox(flask_client):
|
||||
"""make sure user unverified mailbox is not shown to user"""
|
||||
user = login(flask_client)
|
||||
db.session.commit()
|
||||
|
||||
Mailbox.create(user_id=user.id, email="m1@example.com", verified=True)
|
||||
Mailbox.create(user_id=user.id, email="m2@example.com", verified=False)
|
||||
db.session.commit()
|
||||
|
||||
r = flask_client.get(url_for("dashboard.custom_alias"),)
|
||||
|
||||
assert "m1@example.com" in str(r.data)
|
||||
assert "m2@example.com" not in str(r.data)
|
||||
|
|
Loading…
Reference in a new issue