Skip to content

Commit 10c0585

Browse files
committed
added Password Manager
1 parent 77ad7ff commit 10c0585

File tree

146 files changed

+2791
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2791
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
venv
3+
__pycache__/
4+
Data
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ApplicationWindows.login_window import LoginWindow
2+
from ApplicationWindows.signup_window import SignupWindow
3+
from ApplicationWindows.add_window import AddWindow
4+
from ApplicationWindows.retrieve_window import RetrieveWindow
5+
from ApplicationWindows.reset_window import ResetWindow
6+
from ApplicationWindows.about_window import AboutWindow
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from widgets import *
2+
3+
4+
class AboutWindow(Window):
5+
"""About window of the application"""
6+
7+
def __init__(self, parent, controller):
8+
super().__init__(parent, controller)
9+
10+
# Creating the navigation bar menus
11+
self.nav_bar.add_nav_menu(
12+
"SignUp",
13+
action=lambda: self.controller.show_window("SignupWindow")
14+
)
15+
self.nav_bar.add_nav_menu(
16+
"Login",
17+
action=lambda: self.controller.show_window("LoginWindow")
18+
)
19+
self.nav_bar.add_nav_menu(
20+
"About",
21+
action=lambda: self.controller.show_window("AboutWindow"),
22+
is_active=True
23+
)
24+
25+
# Adding the page to the body
26+
self.add_pages(PageOne)
27+
28+
self.body.show_frame(PageOne)
29+
30+
31+
class PageOne(TwoColumnBody):
32+
33+
def __init__(self, parent, controller):
34+
super().__init__(parent, controller)
35+
36+
self.add_image(self.root_controller.images["reset_window"]["page_one"])
37+
self.left_frame.config(pady=45)
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
from widgets import *
2+
from tkinter import messagebox
3+
from functions import generate_password
4+
5+
6+
class AddWindow(Window):
7+
8+
def __init__(self, parent, controller):
9+
super().__init__(parent, controller)
10+
11+
self.nav_bar.add_nav_menu(
12+
label="Add",
13+
action=lambda: self.controller.show_window("AddWindow"),
14+
is_active=True
15+
)
16+
self.nav_bar.add_nav_menu(
17+
label="Retrieve",
18+
action=lambda: self.controller.show_window("RetrieveWindow"),
19+
)
20+
self.nav_bar.add_nav_menu(
21+
label="Logout",
22+
action=lambda: self.logout(),
23+
)
24+
25+
self.password_saved_successfully = False
26+
27+
self.website_name = StringVar()
28+
self.website_url = StringVar()
29+
self.username = StringVar()
30+
self.password = StringVar()
31+
32+
self.add_pages(PageOne)
33+
34+
def logout(self):
35+
"""Logout the user"""
36+
37+
# Take user confirmation
38+
user_response = messagebox.askyesno(
39+
title="Confirm Logout",
40+
message="DO YOU WANT TO LOG OUT OF YOUR ACCOUNT?"
41+
)
42+
43+
# If the user confirmed logout, then log him out of the account
44+
if user_response:
45+
self.controller.logout_of_the_account()
46+
47+
48+
class PageOne(Body):
49+
50+
def __init__(self, parent, controller, **kw):
51+
super().__init__(parent, controller, **kw)
52+
53+
self.config(pady=110, padx=70)
54+
55+
self.website_name_entry = SingleRowInputBox(
56+
self,
57+
label="Website / Application name:",
58+
var=self.parent_window.website_name
59+
)
60+
self.website_url_entry = SingleRowInputBox(
61+
self,
62+
label="Website URL (optional):",
63+
var=self.parent_window.website_url
64+
)
65+
self.username_entry = SingleRowInputBox(
66+
self,
67+
label="Username:",
68+
var=self.parent_window.username
69+
)
70+
self.password_entry = SingleRowInputBox(
71+
self,
72+
label="Password:",
73+
var=self.parent_window.password
74+
)
75+
76+
self.add_inputs(
77+
[self.website_name_entry, self.website_url_entry, self.username_entry, self.password_entry],
78+
from_row=1
79+
)
80+
81+
self.website_name_entry.entry.config(width=48)
82+
self.website_url_entry.entry.config(width=52)
83+
self.username_entry.entry.config(width=64)
84+
self.password_entry.entry.config(width=47)
85+
86+
self.generate_password_btn = ttk.Button(
87+
self,
88+
text="Generate password",
89+
command=lambda: self.show_random_password(),
90+
)
91+
self.generate_password_btn.config(width=20, style="ToggleButton")
92+
self.generate_password_btn.grid(row=4, column=1, pady=(2, 0), sticky=E)
93+
94+
self.add_btn = MyButton(
95+
self,
96+
text="Save Password",
97+
command=lambda: self.save_password(),
98+
)
99+
self.add_btn.grid(row=5, column=0, columnspan=2, pady=(15, 30))
100+
self.add_btn.config(width=20)
101+
102+
self.website_name_entry.entry.bind("<Return>", lambda e: self.website_url_entry.entry.focus_set())
103+
self.website_url_entry.entry.bind("<Return>", lambda e: self.username_entry.entry.focus_set())
104+
self.username_entry.entry.bind("<Return>", lambda e: self.password_entry.entry.focus_set())
105+
self.password_entry.entry.bind("<Return>", lambda e: self.save_password())
106+
107+
def show_random_password(self):
108+
"""Shows a random password"""
109+
random_password = generate_password()
110+
self.parent_window.password.set(random_password)
111+
112+
def save_password(self):
113+
"""Saves the password"""
114+
115+
user_email = self.root_controller.currently_logged_in_account.get()
116+
web_name = self.parent_window.website_name.get()
117+
web_url = self.parent_window.website_url.get()
118+
username = self.parent_window.username.get()
119+
password = self.parent_window.password.get()
120+
121+
if user_email is None:
122+
messagebox.showerror(
123+
title="Error",
124+
message="SOME FISHY LOGIN ACTIVITY DETECTED!\nLOGOUT FROM YOUR ACCOUNT AND LOGIN AGAIN TO CONTINUE"
125+
"SAVING PASSWORDS!"
126+
)
127+
return
128+
129+
if web_name.strip() == "" or username.strip() == "" or password.strip() == "":
130+
messagebox.showerror(
131+
title="Error!",
132+
message="FIELDS CANNOT BE EMPTY!"
133+
)
134+
return
135+
136+
self.root_controller.add_new_password(
137+
for_user=user_email, web_name=web_name, web_url=web_url, username=username, password=password
138+
)
139+
140+
# If the user saved a password successfully
141+
if self.parent_window.password_saved_successfully:
142+
143+
self.parent_window.website_name.set("")
144+
self.parent_window.website_url.set("")
145+
self.parent_window.username.set(user_email)
146+
self.parent_window.password.set("")
147+
148+
# Resetting the variable
149+
self.parent_window.password_saved_successfully = False
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
from widgets import *
2+
from tkinter import messagebox
3+
4+
5+
class LoginWindow(Window):
6+
"""Login window of the application"""
7+
8+
def __init__(self, parent, controller):
9+
super().__init__(parent, controller)
10+
11+
# Creating the navigation bar menus
12+
self.nav_bar.add_nav_menu(
13+
"SignUp",
14+
action=lambda: self.controller.show_window("SignupWindow"),
15+
)
16+
self.nav_bar.add_nav_menu(
17+
"Login",
18+
action=lambda: self.controller.show_window("LoginWindow"),
19+
is_active=True
20+
)
21+
self.nav_bar.add_nav_menu(
22+
"About",
23+
action=lambda: self.controller.show_window("AboutWindow"),
24+
)
25+
26+
# Variables to store inputs
27+
self.email = StringVar()
28+
self.password = StringVar()
29+
30+
# Adding the page to the body
31+
self.add_pages(PageOne)
32+
33+
self.show_page("PageOne")
34+
35+
def login_to_account(self):
36+
"""Log in to the account"""
37+
38+
# Getting the entered email and password
39+
email = self.email.get()
40+
password = self.password.get()
41+
42+
if email.strip() == "" or password.strip() == "":
43+
messagebox.showerror(
44+
title="Login Error",
45+
message=f"FIELDS CANNOT BE EMPTY!"
46+
)
47+
return
48+
49+
# Logging in the user
50+
self.controller.login_to_account(email, password)
51+
52+
# Resetting the input fields
53+
logged_in_account = self.controller.currently_logged_in_account.get()
54+
if logged_in_account != NONE:
55+
self.email.set("")
56+
57+
self.password.set("")
58+
59+
60+
class PageOne(TwoColumnBody):
61+
62+
def __init__(self, parent, controller):
63+
super().__init__(parent, controller)
64+
65+
self.add_image(self.root_controller.images["login_window"]["page_one"])
66+
67+
self.email_input = TwoRowsInputBox(
68+
self.right_frame,
69+
label="Enter your email: ",
70+
var=self.parent_window.email
71+
)
72+
self.password_input = TwoRowsInputBox(
73+
self.right_frame,
74+
label="Enter your password: ",
75+
var=self.parent_window.password
76+
)
77+
self.password_input.entry.config(show="*")
78+
79+
self.add_inputs([self.email_input, self.password_input])
80+
81+
self.show_pass_var = IntVar()
82+
show_password = ttk.Checkbutton(
83+
self.right_frame,
84+
text="Show Password",
85+
variable=self.show_pass_var,
86+
command=lambda: self.toggle_password_visibility()
87+
)
88+
show_password.grid(row=2, column=0, pady=(20, 0), sticky=W)
89+
90+
self.forgot_password_btn = Button(
91+
self.right_frame,
92+
text="Forgot Password?",
93+
command=lambda: self.root_controller.show_window("ResetWindow"),
94+
bg=BODY_COLOR,
95+
fg=COLORS["pink"],
96+
font=(MASTER_FONT, 10),
97+
highlightthickness=0,
98+
borderwidth=0,
99+
cursor="circle",
100+
activebackground=COLORS["pink"],
101+
activeforeground=TEXT_COLOR,
102+
)
103+
self.forgot_password_btn.grid(row=2, column=1, pady=(20, 0), sticky=E)
104+
105+
self.login_btn = MyButton(
106+
self.right_frame,
107+
text="Login",
108+
command=lambda: self.parent_window.login_to_account()
109+
)
110+
self.login_btn.grid(row=3, column=0, columnspan=2, pady=(30, 0))
111+
112+
self.right_frame.config(pady=80)
113+
114+
self.email_input.entry.bind("<Return>", lambda e: self.password_input.entry.focus_set())
115+
self.password_input.entry.bind("<Return>", lambda e: self.parent_window.login_to_account())
116+
117+
def toggle_password_visibility(self):
118+
"""Toggles the visibility of the password input"""
119+
value = self.show_pass_var.get()
120+
if value == 1:
121+
self.password_input.entry.config(show="")
122+
else:
123+
self.password_input.entry.config(show="*")

0 commit comments

Comments
 (0)