Skip to content

Commit e7f2853

Browse files
committed
update form and register util
1 parent cf564de commit e7f2853

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Author Steven Yeoh
22
# Copyright (c) 2019. All rights reserved.
33

4-
from exercises.utils.form_util import get_form
4+
from exercises.utils.form_util import display_form
55

66
print("\n=========================== MENU ===========================")
77
print(" [R]egister account")
88
print(" [L]ogin")
9-
user_option = input(" Enter your option: ").upper()
9+
user_option = input(" Enter option: ").upper()
1010
print("=========================== MENU ===========================")
11-
get_form(user_option)
11+
display_form(user_option)
1212

1313

exercises/utils/form_util.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# Author Steven Yeoh
22
# Copyright (c) 2019. All rights reserved.
33

4-
from exercises.utils import login_util, register_util
4+
from getpass import getpass
5+
from exercises.utils import register_util, validate_util
56

67

7-
def get_form(option):
8-
if option == "R":
8+
def display_form(user_option):
9+
if user_option == "R":
910
register_form()
10-
elif option == "M":
11+
elif user_option == "M":
1112
login_form()
1213
else:
13-
print("Invalid option, please try again.")
14+
print("Incorrect option, please try again.")
1415

1516

1617
def register_form():
1718
print("\n=========================== REGISTER ===========================")
1819
username = input(" Enter username: ")
19-
password = input(" Enter password: ")
20-
confirm_password = input(" Enter confirm password: ")
21-
print("=========================== REGISTER ===========================")
20+
password = getpass(" Password: ")
21+
confirm_password = getpass(" Enter confirm password: ")
22+
print("=========================== REGISTER ===========================\n")
23+
errors = validate_util.validate_user_input(username, password, confirm_password)
24+
validate_util.print_errors(errors) if bool(errors) else register_util.add_new_user(username, password)
2225

2326

2427
def login_form():

exercises/utils/register_util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# Author Steven Yeoh
22
# Copyright (c) 2019. All rights reserved.
33

4+
5+
def add_new_user(username, password):
6+
# store into txt file
7+
print("Successfully created user, {}.".format(username))
8+

0 commit comments

Comments
 (0)