fixing login email case sensitivity issues
This commit is contained in:
@ -43,17 +43,28 @@ def login():
|
||||
errors.append("enter a valid email address")
|
||||
|
||||
if len(errors) == 0:
|
||||
token = get_model().login(email)
|
||||
result = get_model().login(email)
|
||||
token = result[0]
|
||||
ignoreCaseMatches = result[1]
|
||||
if token is None:
|
||||
errors.append("too many logins. please use one of the existing login links that have been emailed to you")
|
||||
else:
|
||||
link = f"{current_app.config['BASE_URL']}/auth/magic/{token}"
|
||||
|
||||
message = (f"Navigate to {link} to log into Capsul.\n"
|
||||
"\nIf you didn't request this, ignore this message.")
|
||||
|
||||
if len(ignoreCaseMatches) > 0:
|
||||
joinedMatches = " or ".join(ignoreCaseMatches)
|
||||
message = (f"You tried to log in as '{email}', but that account doesn't exist yet. "
|
||||
"If you would like to create a new account for '{email}', click here {link} "
|
||||
"If you meant to log in as {joinedMatches}, please return to capsul.org "
|
||||
"and log in again with the correct (case-sensitive) email address.")
|
||||
|
||||
current_app.config["FLASK_MAIL_INSTANCE"].send(
|
||||
Message(
|
||||
"Click This Link to Login to Capsul",
|
||||
body=(f"Navigate to {link} to log into Capsul.\n"
|
||||
"\nIf you didn't request this, ignore this message."),
|
||||
body=message,
|
||||
recipients=[email]
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user