def test_change_password(self): logged_user = sql_manager.login('Tester', 'asdaFGG45g*&') new_password = "******" sql_manager.change_pass(new_password, logged_user) logged_user_new_password = sql_manager.login('Tester', new_password) self.assertEqual(logged_user_new_password.get_username(), 'Tester')
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(" ") if command[0] == "register": username = input("Enter your username: "******"stty -echo") password = input("Enter your password: "******"stty echo") email = input("Enter your email address: ") print(sql_manager.register(username, password, email)) elif command[0] == "login": username = input("Enter your username: "******"stty -echo") password = input("Enter your password: "******"stty echo") logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command[0] == "reset-password": if not sql_manager.check_if_username_exists(command[1]): print("Invalid username/password.") else: sql_manager.clear_login_attempts(command[1]) sql_manager.send_reset_password(command[1]) correct = False while correct is False: probable_hash = input("Please enter the code you have received in the email: ") if sql_manager.check_if_hashes_match(command[1], probable_hash): correct = True sql_manager.login(command[1], probable_hash) os.system("stty -echo") new_password = input("Please enter your new password: "******"stty echo") while sql_manager.check_password_strength(command[1], new_password) is False: os.system("stty -echo") new_password = input("Please enter a valid password: "******"stty echo") sql_manager.change_pass(new_password, command[1]) elif command[0] == "help": print("help - for displaying this message!") print("login - for logging in!") print("register - for creating new account!") print("reset-password <username> - for resetting forgotten password!") print("exit - for closing program!") elif command == "exit": break else: print("Not a valid command")
def test_login_wrong_password_5_in_row(self): logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') self.assertFalse(logged_user)
def test_multiple_login_wrong_password1(self): logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123') self.assertEqual(logged_user.get_username(), 'Tester')
def test_change_password(self): logged_user = sql_manager.login('Tester', '123') new_password = "******" sql_manager.change_pass(new_password, logged_user) logged_user_new_password = sql_manager.login('Tester', new_password) self.assertEqual(logged_user_new_password.get_username(), 'Tester')
def test_change_password(self): logged_user = sql_manager.login("Tester", STRONG_PASSWORD1) new_password = "******" sql_manager.change_pass(new_password, logged_user) logged_user_new_password = sql_manager.login("Tester", new_password) self.assertEqual(logged_user_new_password.get_username(), "Tester")
def login(): username = input("Enter your username: "******"Enter your password: ") try: sql_manager.login(username, password) logged_menu(username) except UnsuccessfulLoginException as e: print(e)
def test_change_password_with_sql_injection(self): sql_manager.register('Dinko', STRONG_PASSWORD1) sql_manager.register('Vladko', STRONG_PASSWORD2) logged_user = sql_manager.login('Dinko', STRONG_PASSWORD1) new_password = "******" sql_manager.change_pass(new_password, logged_user) self.assertFalse(sql_manager.login('Vladko', "1234Asdf$$$Asdf"))
def test_login(self): logged_user = sql_manager.login('Tester', '123qwe@AS') self.assertEqual(logged_user.get_username(), 'Tester') logged_user = sql_manager.login('\' OR 1==1--', '123') self.assertFalse(logged_user) logged_user = sql_manager.login('Blq', '\' OR 1==1--') self.assertEqual(False, logged_user)
def test_login(self): logged_user = sql_manager.login('Tester', '123qwe@AS') self.assertEqual(logged_user.get_username(), 'Tester') logged_user = sql_manager.login('\' OR 1==1--', '123') self.assertFalse(logged_user) logged_user = sql_manager.login('Blq', '\' OR 1==1--') self.assertEqual(False,logged_user)
def test_login(self): self.assertEqual( True, isinstance(sql_manager.login("user1", "Tu6^^^pass1"), client.Client)) self.assertEqual( False, isinstance(sql_manager.login("user1", "' OR 1 = 1 --"), client.Client)) self.assertEqual( False, isinstance(sql_manager.login("' OR 1 = 1 --", "fsjfljkd"), client.Client))
def main_menu(conn, cursor): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter a username: "******"Enter a password: "******"Enter a password again: ") print("WEAK password") sql_manager.register(conn, cursor, username, password) print("Registration Successfull") elif command == 'login': count_wrong_input = 0 username = input("Enter your username: "******"" while not sql_manager.login(conn, cursor, username, password): password = getpass.getpass(prompt="Enter your password: "******"You entered wrong password 5 times!") boom = 30 while boom >= 0: time.sleep(1) print("You can enter you password again after:{}sec". format(boom), end='\r') boom -= 1 count_wrong_input = 0 logged_user = sql_manager.login(conn, cursor, username, password) if logged_user: logged_menu(conn, cursor, logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def start(self): print(messages.WELCOME_MSG) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your username: "******"Enter your password: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': result = print_username_password() username = result['username'] password = result['password'] inp = sql_manager.register(username, password) if inp == True: print("Registration Successfull") else: print(inp['reason']) elif command == 'login': result = print_username_password() username = result['username'] password = result['password'] logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command == 'help': print_help() elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. " "\nPlease register or login") while True: command = input("$$$> ") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': result = print_username_password() username = result['username'] password = result['password'] inp = sql_manager.register(username, password) if inp: print("Registration Successfull") else: print(inp['reason']) elif command == 'login': result = print_username_password() username = result['username'] password = result['password'] logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command == 'help': print_help() elif command == 'exit': break else: print("Not a valid command")
def main_menu(): failed_log_users = [1] fail_log_counter = 0 wrong_pass_limit = 5 block_message = "you have 5 wrong password inputs\ \n and you`re blocked for 5 minutes" print("Welcome to our bank service. You are not logged in.\ \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your emal: ") sql_manager.register(username, hashed_pass, email) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(conn, cursor): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter a username: "******"Enter a password: "******"Enter a password again: ") print("WEAK password") sql_manager.register(conn, cursor, username, password) print("Registration Successfull") elif command == 'login': count_wrong_input = 0 username = input("Enter your username: "******"" while not sql_manager.login(conn, cursor, username, password): password = getpass.getpass(prompt="Enter your password: "******"You entered wrong password 5 times!") boom = 30 while boom >= 0: time.sleep(1) print("You can enter you password again after:{}sec".format(boom), end='\r') boom -= 1 count_wrong_input = 0 logged_user = sql_manager.login(conn, cursor, username, password) if logged_user: logged_menu(conn, cursor, logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_deposit_withdraw(self): logged_user = sql_manager.login('Tester', '123Ab#78') sql_manager.deposit(10000, sql_manager.get_tan(logged_user)[0], logged_user) self.assertEqual(sql_manager.display_balance(logged_user), 10000.00) sql_manager.withdraw(1000, sql_manager.get_tan(logged_user)[1], logged_user) self.assertEqual(sql_manager.display_balance(logged_user), 9000.00)
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") command_array = command.split(" ") if command == 'register': username = input("Enter your username: "******"Your Pasword is to short, it must be 8 symbols") elif not have_upper_letters(password): print("Your password must have upper letters") elif not number_function(password): print("Your password must have numbers") elif not have_special(password): print("It must have special symbols") elif username in password: print("Don`t use your name in your password") else: sql_manager.register(username, sql_manager.get_crypted(password), email) break print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(" ") if command[0] == 'register': username = input("Enter your username: "******"Enter your password: "******"Password is not strong enough!") password = getpass.getpass("Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) print("Registration Successfull") elif command[0] == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command[0] == "reset-password" and len(command) >1: reset_hash = hashlib.sha1(str(random.random()).encode()).hexdigest() sql_manager.update_reset_hash(command[1], reset_hash) send_email.send_email(sql_manager.get_email(command[1]), reset_hash) print(command[1]) elif command[0] == "send-reset-password" and len(command) > 1: reset_hash = input("Enter reset hash: ") if reset_hash == sql_manager.get_reset_hash(command[1]): logged_user = sql_manager.login_with_hash(command[1], reset_hash) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command[0] == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") print("reset-password <name> - to reset password") print("send-reset-password <name> - to enter reset password") elif command[0] == 'exit': break else: print("Not a valid command")
def test_change_pass(self): logged_user = sql_manager.login("user1", "Tu6^^^pass1") sql_manager.change_pass("new_PASS123", logged_user) conn = sqlite3.connect("bank.db") cursor = conn.cursor() select_query = "SELECT id, username, password FROM clients WHERE \ username = ? AND password = ? LIMIT 1" cursor.execute(select_query, ("user1", sql_manager.hash_pass("new_PASS123"))) user = cursor.fetchone() self.assertEqual("user1", user[1])
def login_user(): username = input("Enter your username: "******"Enter your password: "******"Login failed")
def main_menu(): print('\n'.join(["Welcome to our bank service. You are not logged in.", "Please register or login"])) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your email: ") password = getpass("Enter your password: "******"Password should contain an upper and", "a lowercase letter, a digit and a symbol"])) password = getpass("Enter your password: "******"Registration Successfull") elif command == "send-reset-password": username = input("Enter your username: "******"Enter your username: "******"Enter key: ") if not reset_password(username, key): print("Wrong key entered!") else: print('\n'.join(["Password set to aaAA11**", "Please change your password now!"])) elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed", "Maybe you'd entered wrong password more than 5 times?", "If so, you've been blocked for 5 minutes.."])) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): while True: print('''Welcome to our bank service system! You have the following options: 1. Register 2. Log in 3. Help 4. Exit ''') choice = int(input("Input your choice: ")) if choice == 1: username = input("Enter your username: "******"Enter your password: "******"Password must contain 1 uppercase and lowercase letter at\ least and one special symbol and must\ differ from username") password = getpass.getpass("Enter your password: "******"Verify password: "******"Registration Successfull") else: print("Password mismatch. Try again") elif choice == 2: username = input("Enter your username: "******"Enter your password: "******"Login failed") elif choice == 3: os.system("clear") print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif choice == 4: break else: print("Not a valid command")
def login(cls): username = input("Enter your username: "******"Login failed") return username
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") command_array = command.split(" ") if command == 'register': username = input("Enter your username: "******"Your Pasword is to short, it must be 8 symbols") elif not have_upper_letters(password): print("Your password must have upper letters") elif not number_function(password): print("Your password must have numbers") elif not have_special(password): print("It must have special symbols") elif username in password: print("Don`t use your name in your password") else: sql_manager.register(username, sql_manager.get_crypted(password), email) break print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"pass must\n-be more than 8 characters\n -must have capital letters and numbers and a special symbol\n -not containing the username" ) sql_manager.register(username, password) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password <username>") print("Reset-password <username>") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_multiple_login_wrong_password(self): logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123567') logged_user = sql_manager.login('Tester', '123') self.assertEqual(logged_user, "Too many login fails! Try again later!")
def main_menu(): print("Welcome to our bank service. You are not logged in.") print("Please register or login") while True: command = input("$$$>") if command == "register": username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) elif command == "login": username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == "send-reset-password": username = input("Enter your username: "******"reset-password": username = input("Enter your username: "******"Enter the hash code from your email: ") sql_manager.reset_password(username, hash) elif command == "help": print("login - for logging in!") print("register - for creating new account!") print("send-reset-password - to send a " "password reset code to your email!") print( "reset-password - to reset your password using a " "code from your email, to get it use the command above!" ) print("exit - for closing the program!") elif command == "exit": break else: print("Not a valid command")
def login(): username = input("Enter your username: ") password = getpass.getpass('Enter your password:'******'err_index'] == 0: sql_manager.change_last_log_try(username) else: pass print(logged_user['err_mess'])
def main_menu(): print("Welcome to our bank service. You are not logged in.") print("Please register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"Enter your username: "******"Enter the hash code from your email: ") sql_manager.reset_password(username, hash) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("send-reset-password - to send a " \ "password reset code to your email!") print("reset-password - to reset your password using a " \ "code from your email, to get it use the command above!") print("exit - for closing the program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"pass must\n-be more than 8 characters\n -must have capital letters and numbers and a special symbol\n -not containing the username") sql_manager.register(username, password) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password <username>") print("Reset-password <username>") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): faillogin = 0 print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) counter = 0 while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") except Exception as e: print(e) print('Registration failed') elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") if counter % 5 == 0: print('Are you trying to bruteforce?\nSleep now :)') time.sleep(60 * (5**counter / 5)) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(' ') if command[0] == 'register': username = input("Enter your username: "******"Enter your email: ") password = getpass.getpass(prompt='Password: '******'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password [username] - for resetting password!") print("exit - for closing program!") elif command[0] == 'exit': break else: print("Not a valid command")
def main_menu(): global counter print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Password must contain at least one number, one uppercase and lowercase letter and a total length of at least six symbols!" ) return main_menu() print("Registration Successful") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"User and password dont match!") return main_menu() if logged_user: counter = 0 logged_menu(logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): faillogin = 0 print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def login(username): try: if abs(time() - sql_manager.get_current_time(username)) > 300: sql_manager.reset_failed_logins() except IOError: print("No such username.") return if sql_manager.get_attempts(username) < 21: password = getpass("Enter your password: "******"sha1") logged_user = sql_manager.login(username, password) if logged_user: sql_manager.reset_failed_login(username) logged_menu(logged_user) else: sql_manager.failed_login(username) print("Login failed") else: print("Number of login attempts(20) exceeded. Wait 5 minutes before attempting to login.")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'reset-password': recepient = input("username> ") sql_manager.send_email(recepient) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'reset-password': recepient = input("username> ") sql_manager.send_email(recepient) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your email: ") password = getpass("Enter your password: "******"Password is too weak. Use at least 9 characters, uppercase, lowercase, numeric and special characters.") password = input("Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': help_main() elif command == 'exit': break else: print("Not a valid command") help_main()
def login(): username = input("Enter your username: "******"Login failed")
def test_login_wrong_password(self): logged_user = sql_manager.login('Tester', '123567') self.assertFalse(logged_user)
def test_change_message(self): logged_user = sql_manager.login('Tester', '123') new_message = "podaivinototam" sql_manager.change_message(new_message, logged_user) self.assertEqual(logged_user.get_message(), new_message)
def test_login_sql_injection(self): self.assertFalse(sql_manager.login("' OR 1 = 1 --", 'w/e'))
def test_login(self): logged_user = sql_manager.login('Tester', '123') self.assertEqual(logged_user.get_username(), 'Tester')
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass("Enter your new password: "******"Change Successfull") else: print("Change failed") elif command == 'get-tan': user_id = logged_user.get_id() password = getpass.getpass("Enter your password: "******"You have {} remaining TAN codes to use.".format(len(tans_list))) if len(tans_list) == 0: menu_functions.tan_record_operations(logged_user) else: print("Wrong password.") main_menu() elif command == 'change-message': new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'deposit': amount = int(input("Enter amount: ")) tan_code = input("Enter TAN code: ") user_id = logged_user.get_id() tans_list = sql_manager.get_tans_for_user(user_id) if tan_code in tans_list: logged_user = menu_functions.update_deposit_amount(logged_user, amount) sql_manager.remove_used_tan(user_id, tan_code) else: print("Invalid TAN code.") elif command == 'withdraw': amount = int(input("Enter amount: ")) balance = logged_user.get_balance() if amount > balance: print("You do not have that amount of money in your account.") else: amount = -amount logged_user = menu_functions.update_deposit_amount(logged_user, amount) elif command == 'display-balance': balance = logged_user.get_balance() print("Your balance is: {}".format(balance)) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") datetime_fail = datetime.datetime(1900, 1, 1, 0, 0, 0) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") if sql_manager.check_pass(username, password): sql_manager.register(username, hashed_pass, email) print("Registration Successfull") else: print("Registration failed") elif command == 'login': username = input("Enter your username: "******"0:05:00": print("Please try again later.") failed_logins = 0 sql_manager.update_number_of_failed_logins(failed_logins, username) else: if failed_logins < 5: password = getpass.getpass("Enter your password: "******"Login failed") failed_logins += 1 sql_manager.update_number_of_failed_logins(failed_logins, username) else: datetime_fail = menu_functions.current_time() sql_manager.update_failed_datetime(datetime_fail, username) print("You can not login for the next 5 minutes.") elif 'send-reset-password' in command: username = command.split(" ")[1] user_email = sql_manager.get_user_email(username) if user_email is not None: unique_random = str(uuid.uuid4()) sql_manager.update_reset_code(username, unique_random) menu_functions.send_email(user_email, unique_random) else: print("Wrong username or bad input!") elif 'send-reset-password' not in command and "reset-password" in command: username = command.split(" ")[1] hash_code = input("Enter the hash code we sent you: ") if sql_manager.check_hash_code(username, hash_code): new_password = getpass.getpass("Enter your password: "******"Password was reset successfully.") else: print("The hash code you entered is invalid.") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_get_tan(self): logged_user = sql_manager.login('Tester', '123Ab#78') self.assertEqual(10, len(sql_manager.get_tan(logged_user)))
def test_change_message(self): logged_user = sql_manager.login('Tester', '123Ab#78') new_message = "podaivinototam" sql_manager.change_message(new_message, logged_user) self.assertEqual(logged_user.get_message(), new_message)