Skip to content
Permalink
Browse files
Initial upload
  • Loading branch information
hawesa2 committed Nov 7, 2022
1 parent 7e72c0d commit 02a482779e968861460f72c1c8c6bb650a84fe8a
Showing 1 changed file with 40 additions and 0 deletions.
@@ -0,0 +1,40 @@
import Databases.database_interaction as databaseInteraction
from getpass import getpass
#declare global CONSTANTS
MAX_REGISTER_ATTEMPTS = 4
MAX_LOGIN_ATTEMPTS = 4

#omitted code that isn’t mine

#for register
for attempts in range(MAX_REGISTER_ATTEMPTS, 0, -1):
username = input('To register: Enter username >').strip()
password = input('Enter password >')
try:
databaseInteraction.CreateUser(username, password)
return system_type,username,input("Registration and login successful. What would you like to ask me? ")
except: #raised if username not unique
print('Error: Username already exists.')
print('Attempts remaining: ' + str(attempts - 1))

print('Out of attempts. Logging in as Guest.')
return system_type,"Guest",input("What would you like to ask me? ")

#omitted code that isn’t mine

#for login
for attempts in range(MAX_LOGIN_ATTEMPTS, 0, -1):
username = input('To login: Enter username >')
#usage for getpass found from https://stackoverflow.com/a/9202236
password = getpass('Enter password (input hidden) >')
userExists, successful = databaseInteraction.CheckUsernamePasswordMatch(username, password)
if successful:
return system_type,username,input("Login successful. What would you like to ask me? ")
elif userExists:
print('Password incorrect.')
else:
print('Username incorrect.')
print('Attempts remaining: ' + str(attempts - 1))

print('Out of attempts. Logging in as Guest.')
return system_type,"Guest",input("What would you like to ask me? ")

0 comments on commit 02a4827

Please sign in to comment.