🐛 fix style
This commit is contained in:
parent
5c74ad2dc0
commit
30183ac8c3
|
@ -25,7 +25,7 @@ from app.models import (
|
|||
DomainDeletedAlias,
|
||||
AliasSuffixEnum,
|
||||
)
|
||||
from app.utils import random_word, word_exist, random_string
|
||||
from app.utils import random_word, random_string
|
||||
|
||||
signer = TimestampSigner(CUSTOM_ALIAS_SECRET)
|
||||
|
||||
|
@ -251,6 +251,7 @@ def custom_alias():
|
|||
mailboxes=mailboxes,
|
||||
)
|
||||
|
||||
|
||||
def get_suffix(user: User) -> str:
|
||||
"""Get random suffix for an alias based on user's preference.
|
||||
|
||||
|
@ -261,9 +262,10 @@ def get_suffix(user: User) -> str:
|
|||
str: the random suffix generated
|
||||
"""
|
||||
if user.random_alias_suffix == AliasSuffixEnum.rnd_string.value:
|
||||
return random_string(ALIAS_RAND_SUFFIX_LENGTH, include_digits = True)
|
||||
return random_string(ALIAS_RAND_SUFFIX_LENGTH, include_digits=True)
|
||||
return random_word()
|
||||
|
||||
|
||||
def verify_prefix_suffix(user: User, alias_prefix, alias_suffix) -> bool:
|
||||
"""verify if user could create an alias with the given prefix and suffix"""
|
||||
if not alias_prefix or not alias_suffix: # should be caught on frontend
|
||||
|
|
|
@ -15,7 +15,12 @@ from wtforms import StringField, validators
|
|||
from wtforms.fields.html5 import EmailField
|
||||
|
||||
from app import s3, email_utils
|
||||
from app.config import URL, FIRST_ALIAS_DOMAIN, JOB_DELETE_ACCOUNT, ALIAS_RAND_SUFFIX_LENGTH
|
||||
from app.config import (
|
||||
URL,
|
||||
FIRST_ALIAS_DOMAIN,
|
||||
JOB_DELETE_ACCOUNT,
|
||||
ALIAS_RAND_SUFFIX_LENGTH,
|
||||
)
|
||||
from app.dashboard.base import dashboard_bp
|
||||
from app.email_utils import (
|
||||
email_can_be_used_as_mailbox,
|
||||
|
|
|
@ -161,10 +161,12 @@ class AliasGeneratorEnum(EnumE):
|
|||
word = 1 # aliases are generated based on random words
|
||||
uuid = 2 # aliases are generated based on uuid
|
||||
|
||||
|
||||
class AliasSuffixEnum(EnumE):
|
||||
word = 0 # Random word from dictionary file
|
||||
rnd_string = 1 # Completely random string
|
||||
|
||||
|
||||
class Fido(db.Model, ModelMixin):
|
||||
__tablename__ = "fido"
|
||||
credential_id = db.Column(db.String(), nullable=False, unique=True, index=True)
|
||||
|
@ -294,7 +296,8 @@ class User(db.Model, ModelMixin, UserMixin):
|
|||
# Random word from dictionary file -> 0
|
||||
# Completely random string -> 1
|
||||
random_alias_suffix = db.Column(
|
||||
db.Integer, nullable=False,
|
||||
db.Integer,
|
||||
nullable=False,
|
||||
default=AliasSuffixEnum.rnd_string.value,
|
||||
server_default=str(AliasSuffixEnum.rnd_string.value),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue