def create_account(): print(' ****************** REGISTER **************** ') name = input('What is your name? ') email = input('What is your email? ').strip().lower() old_account = svc.find_account_by_email(email) if old_account: error_msg(f"ERROR: Account with email {email} already exists.") return state.active_account = svc.create_account(name, email) success_msg(f"Created new account with id {state.active_account.id}.")
def create_account(): print(' ****************** REGISTER **************** ') # done: Get name & email name = input('name') email = input('email') # Done: Create account, set as logged in. old_acount = svc.find_account_by_email(email) if old_acount: error_msg("Error, that email already exists") return state.active_account = svc.create_account(name, email) success_msg(f"created an account with id {state.active_account.id}")
def log_into_account(): print(' ******************** Select user ******************** ') for user_tuple in set_up_globals.users: name = user_tuple[0] email = user_tuple[1] if not svc.find_account_by_email(email): svc.create_account(name, email) users = svc.get_users() print() for idx, u in enumerate(users): print('{}. {} (email: {})'.format( idx + 1, u.name, u.email )) message = f"\nPlease enter a number between 1 and {str(len(users))} or 'x' to exit: " response = input(message) if response in set_up_globals.exitResponseList: return response try: user = users[int(response) - 1] except (IndexError, ValueError): error_msg(message + '\n') return response email = user.email account = svc.find_account_by_email(email) if not account: error_msg(f'Could not find account with email {email}.') return response state.active_account = account success_msg('Logged in successfully.')
def create_account(): print(' ****************** REGISTER **************** ') first_name = input('What is your first name? ') last_name = input('What is your last name? ') username = input( 'What would you like your username to be? ').strip().lower() email = input('What is your email? ').strip().lower() account_exists = svc.find_account_by_email(email) if account_exists: error_msg(f"ERROR: Account with email {email} already exists.") return state.active_account = svc.create_account(username, first_name, last_name, email) success_msg(f"Created new account with id {state.active_account.id}.")
def log_into_account(): print(' ****************** LOGIN **************** ') emailregex = re.compile( r'^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$') email = emailregex.search(input('Enter your Email : ').strip().lower()) if not email: error_msg(f'Not an Email') return account = svc.find_account_by_email(email.group()) if not account: success_msg(f'could not find User with email {email.group()}') return state.active_account = account success_msg(f'Logged in with no issues.')
def create_account(): print(' ****************** REGISTER **************** ') name = input('Enter your Name : ') emailregex = re.compile( r'^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$') email = emailregex.search(input('Enter your Email : ').strip().lower()) if not email: error_msg(f'Not an Email') return old_account = svc.find_account_by_email(email.group()) if old_account: error_msg(f'Account with email - {email} already exists.') return state.active_account = svc.create_account(name, email.group()) success_msg( f'New Account {state.active_account.id} with email - {email.group()} created at {datetime.datetime.now()}' )
def reload_account(): global active_account if not active_account: return active_account = svc.find_account_by_email(active_account.email)