-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_passwd.py
96 lines (91 loc) · 4.66 KB
/
f_passwd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
#creating window
class Fp(Tk):
def __init__(self):
super().__init__()
self.iconbitmap(r'libico.ico')
self.maxsize(500, 400)
self.minsize(500, 400)
self.title("Forget Password")
#creating variables
a = StringVar()
b = StringVar()
c = StringVar()
d = StringVar()
e = StringVar()
#verifying input
def ins():
if (len(d.get())) < 8 or len(e.get()) < 8:
while True:
if not re.search("[a-z]", d.get()):
flag = -1
break
elif not re.search("[A-Z]", d.get()):
flag = -1
break
elif not re.search("[0-9]", d.get()):
flag = -1
break
elif not re.search("[_@$]", d.get()):
flag = -1
break
elif re.search("\s", d.get()):
flag = -1
break
else:
flag = 0
break
if len(d.get()) == 0:
messagebox.showinfo("Error","Please Enter Your Password")
elif flag == -1:
messagebox.showinfo("Error","Minimum 8 characters.\nThe alphabets must be between [a-z]\nAt least one alphabet should be of Upper Case [A-Z]\nAt least 1 number or digit between [0-9].\nAt least 1 character from [ _ or @ or $ ].")
elif d.get() != e.get():
messagebox.showinfo("Error","New and retype password are not some")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Update admin set password = ? where id = ?",[e.get(),a.get()])
self.conn.commit()
self.myCursor.close()
self.conn.close()
messagebox.showinfo("Confirm","Password Updated Successfuly")
self.destroy()
except Error:
messagebox.showerror("Error","Something Goes Wrong")
def check():
if len(a.get()) < 5:
messagebox.showinfo("Error","Please Enter User Id")
elif len(b.get()) == 0:
messagebox.showinfo("Error","Please Choose a question")
elif len(c.get()) == 0:
messagebox.showinfo("Error", "Please Enter a answer")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Select id,secQuestion,secAnswer from admin where id = ?",[a.get()])
pc = self.myCursor.fetchone()
if not pc:
messagebox.showinfo("Error", "Something Wrong in the Details")
elif str(pc[0]) == a.get() or str(pc[1]) == b.get() or str(pc[2]) == c.get():
Label(self, text="New Password", font=('arial', 15, 'bold')).place(x=40, y=220)
Entry(self, show = "*", textvariable=d, width=40).place(x=230, y=224)
Label(self, text="Retype Password", font=('arial', 15, 'bold')).place(x=40, y=270)
Entry(self, show = "*", textvariable=e, width=40).place(x=230, y=274)
Button(self, text="Submit", width=15, command=ins).place(x=230, y=324)
except Error:
messagebox.showerror("Error","Something Goes Wrong")
#label and input box
Label(self, text="Enter User Id", font=('arial', 15, 'bold')).place(x=40, y=20)
Label(self, text="Security Question",font=('arial', 15, 'bold')).place(x=40, y= 70)
Label(self, text="Security Answer",font=('arial', 15, 'bold')).place(x=40, y= 120)
Entry(self, textvariable=a, width=40).place(x=230, y=24)
ttk.Combobox(self, textvariable = b,values=["What is your school name?", "What is your home name?","What is your Father name?", "What is your pet name?"], width=37,state="readonly").place(x=230, y=74)
Entry(self, show = "*", textvariable=c, width=40).place(x=230, y=124)
Button(self, text='Verify', width=15,command = check).place(x=230, y=170)
Fp().mainloop()