I have two challenges one is that when a user tries to login with the wrong password, the system does not allow the attempt which is okay but the the system does not allow room for another attempt it just stops
The second one is that when the user is signing up on the sign up page the system allows the user to signup but the button which should be bringing the login page doesn't work logging in
def handle_connection(self):
self.username = self.username.get()
self.password = self.password.get()
self.password = hashlib.sha256(self.password.encode()).hexdigest()
conn = sqlite3.connect("userdata.db")
cur = conn.cursor()
root.after(1000,)
# NUMBER OF ATTEMPTS ALLOWED
max_attempts = 5
attempts = 0
while True:
cur.execute(
"SELECT * FROM light_users WHERE username = ? AND password = ?",
(self.username, self.password)
)
if cur.fetchall():
messagebox.showinfo("Login Successful !")
break
else:
messagebox.showerror("Login Failed !", "Wrong password
or username !\n Please try again !")
break
attempts += 1
if attempts == max_attempts:
messagebox.showerror("Max Login Attempts Exceeded, \n "
"You have reached the maximum number of login attempts."
" Please try again later or contact support.")
signing up block
def check_sign_up(self):
conn = sqlite3.connect("userdata.db")
cur = conn.cursor()
if self.password2.get() == self.password1.get() and self.email.get() != "":
# self.password1 == self.password1.get()
# self.password1 = self.password1.get()
self.password1 = hashlib.sha256(self.password1.get().encode()).hexdigest()
cur.execute("""CREATE TABLE IF NOT EXISTS light_users (
id INTEGER PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
Email VARCHAR(255) NOT NULL)""")
cur.execute("INSERT INTO light_users (username, password, Email) VALUES (?,?,?)",
(self.username.get(), self.password1, self.email.get()))
conn.commit()
messagebox.showinfo("SUCCESS", "Thank you for Joining the Light Technologies")
else:
messagebox.showerror("E R R O R", "All fields are required !!")
root = Tk()
obj = Login(root)
root.mainloop()