fixing bugs with email ignore case feature
This commit is contained in:
parent
ff38858c74
commit
eba3bd6a5a
@ -55,10 +55,10 @@ def login():
|
|||||||
"\nIf you didn't request this, ignore this message.")
|
"\nIf you didn't request this, ignore this message.")
|
||||||
|
|
||||||
if len(ignoreCaseMatches) > 0:
|
if len(ignoreCaseMatches) > 0:
|
||||||
joinedMatches = " or ".join(ignoreCaseMatches)
|
joinedMatches = " or ".join(map(lambda x: f"'{x}'", ignoreCaseMatches))
|
||||||
message = (f"You tried to log in as '{email}', but that account doesn't exist yet. "
|
message = (f"You tried to log in as '{email}', but that account doesn't exist yet. \n"
|
||||||
"If you would like to create a new account for '{email}', click here {link} "
|
f"If you would like to create a new account for '{email}', click here {link} \n\n"
|
||||||
"If you meant to log in as {joinedMatches}, please return to capsul.org "
|
f"If you meant to log in as {joinedMatches}, please return to https://capsul.org \n"
|
||||||
"and log in again with the correct (case-sensitive) email address.")
|
"and log in again with the correct (case-sensitive) email address.")
|
||||||
|
|
||||||
current_app.config["FLASK_MAIL_INSTANCE"].send(
|
current_app.config["FLASK_MAIL_INSTANCE"].send(
|
||||||
|
@ -15,8 +15,8 @@ class DBModel:
|
|||||||
everLoggedIn = len(self.cursor.fetchall())
|
everLoggedIn = len(self.cursor.fetchall())
|
||||||
ignoreCaseMatches = []
|
ignoreCaseMatches = []
|
||||||
if everLoggedIn == 0:
|
if everLoggedIn == 0:
|
||||||
self.cursor.execute("SELECT email FROM accounts WHERE lower_case_email = %s", (email.lower(), ))
|
self.cursor.execute("SELECT email FROM accounts WHERE lower_case_email = %s AND email != %s", (email.lower(), email))
|
||||||
ignoreCaseMatches = self.cursor.fetchall()
|
ignoreCaseMatches = list(map(lambda x: x[0], self.cursor.fetchall()))
|
||||||
|
|
||||||
if hasExactMatch == 0:
|
if hasExactMatch == 0:
|
||||||
self.cursor.execute("INSERT INTO accounts (email, lower_case_email) VALUES (%s, %s)", (email, email.lower()))
|
self.cursor.execute("INSERT INTO accounts (email, lower_case_email) VALUES (%s, %s)", (email, email.lower()))
|
||||||
|
Loading…
Reference in New Issue
Block a user