add website_name to suggested_emails
This commit is contained in:
parent
779cb9c377
commit
8e9aef1199
|
@ -168,19 +168,22 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
else:
|
else:
|
||||||
return url_for("static", filename="default-avatar.png")
|
return url_for("static", filename="default-avatar.png")
|
||||||
|
|
||||||
def suggested_emails(self) -> (str, [str]):
|
def suggested_emails(self, website_name) -> (str, [str]):
|
||||||
"""return suggested email and other email choices """
|
"""return suggested email and other email choices """
|
||||||
|
website_name = convert_to_id(website_name)
|
||||||
|
|
||||||
all_gen_emails = [ge.email for ge in GenEmail.filter_by(user_id=self.id)]
|
all_gen_emails = [ge.email for ge in GenEmail.filter_by(user_id=self.id)]
|
||||||
if self.can_create_new_random_alias():
|
if self.can_create_new_custom_alias():
|
||||||
# create a new email
|
suggested_gen_email = GenEmail.create_custom_alias(
|
||||||
suggested_gen_email = generate_email()
|
self.id, prefix=website_name
|
||||||
|
).email
|
||||||
else:
|
else:
|
||||||
# pick an email from the list of gen emails
|
# pick an email from the list of gen emails
|
||||||
suggested_gen_email = random.choice(all_gen_emails)
|
suggested_gen_email = random.choice(all_gen_emails)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
suggested_gen_email,
|
suggested_gen_email,
|
||||||
list(set(all_gen_emails).difference(set([suggested_gen_email]))),
|
list(set(all_gen_emails).difference({suggested_gen_email})),
|
||||||
)
|
)
|
||||||
|
|
||||||
def suggested_names(self) -> (str, [str]):
|
def suggested_names(self) -> (str, [str]):
|
||||||
|
|
|
@ -100,7 +100,7 @@ def authorize():
|
||||||
LOG.debug("user %s has already allowed client %s", current_user, client)
|
LOG.debug("user %s has already allowed client %s", current_user, client)
|
||||||
user_info = client_user.get_user_info()
|
user_info = client_user.get_user_info()
|
||||||
else:
|
else:
|
||||||
suggested_email, other_emails = current_user.suggested_emails()
|
suggested_email, other_emails = current_user.suggested_emails(client.name)
|
||||||
suggested_name, other_names = current_user.suggested_names()
|
suggested_name, other_names = current_user.suggested_names()
|
||||||
email_suffix = random_string(6)
|
email_suffix = random_string(6)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue