Exemplo n.º 1
0
def read(user_account_number):
    # Find user with account number
    # Fetch content of the file

    # Validating the user's account number
    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    try:

        if is_valid_account_number:
            # If the account number is validated, read the text file
            f = open(user_db_path + str(user_account_number) + ".txt", "r")
        else:
            # If the account number isn't validated, read the file
            f = open(user_db_path + str(user_account_number), "r")

    except FileNotFoundError:
        print("User Not Found.")
    except FileExistsError:
        print("User doesn't exist.")
    except TypeError:
        print("Invalid account number format.")
    else:
        return f.readline()

    return False
Exemplo n.º 2
0
def read(user_account_number):
    # find user with account number
    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    try:
        if is_valid_account_number:
            f = open(user_db_path + str(user_account_number) + ".txt", "r")
        else:
            f = open(user_db_path + user_account_number, "r")

        # fetch the content of the file

    except FileNotFoundError:
        print("File Not Found")

    except FileExistsError:
        print("User Doesnt Exist")

    except TypeError:
        print('Invalid Account Number Format')

    else:
        return f.readline()

    return False
Exemplo n.º 3
0
def login():
    print("Login to Your Account")
    global account_number_from_user

    account_number_from_user = input("What is Your Account Number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is Your Password? \n")

        user = database.authenticated_user(account_number_from_user, password)
        print(user)
        if user:
            bank_operation(user)

        print("Invalid Account Number or Password")
        login()

    else:
        print(
            "Account Number Invalid: Please enter up to 10 digits and only integers"
        )
        init()
Exemplo n.º 4
0
def read(user_account_number):

    # find user with account number
    # fetch content of the file
    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    try:

        if is_valid_account_number:
            f = open(user_db_path + str(user_account_number) + ".txt", "r")
        else:
            f = open(user_db_path + user_account_number, "r")

    except FileNotFoundError:

        print("User not found")

    except FileExistsError:

        print("User doesn't exist")

    except TypeError:

        print("Invalid account number format")

    else:

        return f.readline()

    return False
Exemplo n.º 5
0
def login():
    print("********* Login ***********")

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = input("What is your password \n")

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            print(user)
            print("in login")
            database.create_auth_session_file(account_number_from_user, user)
            bank_operation(account_number_from_user, user)
            #database.create_auth_session_file(account_number_from_user, user)
            #apparently putting this line of code never created the auth session file and never prints finish login
            print("finish login")

        print('Invalid account or password')
        login()

    else:
        print(
            "Account Number Invalid: check that you have up to 10 digits and only integers"
        )
        init()
Exemplo n.º 6
0
def login():
    print("======= Login =========")

    account_number_from_user = input("What is your account number?\n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("what is your password? \n")

        user = database.authenticate_user(
            account_number_from_user,
            password,
        )

        if user:
            bank_operation(user)

        print("Invalid account or password")
        login()

    else:
        print(
            "Account number invalid. Please check that you entered exactly 10 digits"
        )
        init()
def withdraw():
    # get current balance
    # get amount to withdraw
    # check if current balance > withdraw balance
    # deduct withdrawn amount form current balance
    # display current balance
    current_user_account_number = int(input("Enter your account number: \n"))

    is_account_valid = validation.account_number_validation(
        current_user_account_number)
    if is_account_valid:
        current_user = str.split(database.read(current_user_account_number),
                                 ',')
        print("Your current account balance is " + "NGN" + current_user[4] +
              ".00")

        withdrawal_amount = int(
            input("Enter the amount you want to withdraw: \n"))
        if withdrawal_amount <= int(current_user[4]):
            new_balance = int(current_user[4]) - withdrawal_amount
            print("Please take your cash.")
            # update user account balance
            # database.update(current_user_account_number, 4)
            print("Your new account balance is " + "NGN" + str(new_balance) +
                  ".00 \n")
            print("Thank you for banking with us \n")
            exit()

        else:
            print("Insufficient account balance. Please try again")
            auth.login()
    else:
        print("Invalid account number. Please try again")
        auth.login()
Exemplo n.º 8
0
def login():
    print("********** Login **********")

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password \n")

        user = database.authenticate_user(account_number_from_user, password)

        if user:
            import datetime
            now = datetime.datetime.now()
            print("Current date and time : ")
            print(now.strftime("%Y-%m-%d %H:%M:%S"))
            # print('Welcome %s' %name)
            # print('These are the available options:')
            # print('1. Withdrawal')
            # print('2. Cash Deposit')
            # print('3. Check Balance')
            # print('4. Complaint')
            bank_operation(user)

        else:
            print('Password Incorrect, please try again')
            login()

    else:
        print('Account not found, please try again')
        login()
Exemplo n.º 9
0
def login(): # this is creating the function which will appear after you create an account
    print('===== LOGIN =====')

    account_number_from_user = input('What is your account number? \n') 

    is_valid_account_number = validation.account_number_validation(account_number_from_user) #this is sending the account number the user enters to the "account_number_validation" below
   
    if is_valid_account_number:
    
        #password = input('What is your password? \n')
        password = getpass('What is your password? \n')
        # this allows the user to type hte password without it showing on the screen 

        user = database_readuser.authenticated_user(account_number_from_user, password)

        if user:
            bankoperation(user) 

        #for account_number,user_details in database.items(): #for loop 
            #if account_number == int(user_account_number): #since we are no longer converting the integer when you input the account number (remember you took "int" out), we now have to convert it here
                #if(user_details[3] == password):
                    #bankoperation(user_details) # this is calling the bank operation function

        print('Invalid account or password')
        login() #this function tells the computer to start over at login if it gets to this print statement
    
    else:
        print('Account number invalid. Check that you have no more or less than 10 integers')
        init()
Exemplo n.º 10
0
def login():
    print("********* LOGIN ***********")

    user_account_number = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    if is_valid_account_number:

        password = getpass("What is your password \n")

        user = database.authenticated_user(user_account_number, password)

        if user:
            bank_operation(user)

        print('Invalid account or password')
        login()

    else:
        print(
            "Account Number Invalid: Account Number must be 10 digits INTEGERS only"
        )
        init()
Exemplo n.º 11
0
def login():

    user_account_number = input('Enter your Account Number \n')

    valid_account_number = vd.account_number_validation(user_account_number)

    if valid_account_number:

        user_password = input('Enter your Password \n')

    for account_number, user_details in database.items():
        if account_number == int(user_account_number):
            if user_details[3] == user_password:
                bank_operation(user_details)

    try_again = input(
        'Invalid account or password. Do you want to try again or register?\
        \n 1. (Try Again) \n 2. (Register) \n 3. Enter any other character to exit. \n'
    )
    if try_again == '1':
        login()
    elif try_again == '2':
        register()
    else:
        exit_operation()
Exemplo n.º 12
0
def login():
    print("**** Login ****")

    account_number_user = input("What is your Account Number? \n")

    # Validate the account number from user input
    is_valid_account_number = validation.account_number_validation(
        account_number_user)

    # If account number from user input passes, get password
    if is_valid_account_number:

        # Hiding the user's password when typing it in the commandline
        password = getpass("What is your password? \n")
        # Check if user's account number and password exist in the database
        user = database.authenticate_user(account_number_user, password)

        if user:
            # Need to create file in auth_session/ here
            current_date_time = datetime.now()
            formatted_date_time = current_date_time.strftime(
                "%m/%d/%y %H:%M:%S")
            #print("Last login at %s \n" % formatted_date_time)
            latest_login = database.user_login_timestamp(
                account_number_user, formatted_date_time)
            # If the account number and password exist in the database, carry out bank operations
            bank_operations(account_number_user, user)
        else:
            print("Invalid Account Number or Password.")
            login()

    else:
        # Account number from user input didn't pass validation
        print("Account Number Invalid: Check that you have up to 10 digits.")
        init()
Exemplo n.º 13
0
def login():

    print("********* Login ***********")
    global accountNumberFromUser
    accountNumberFromUser = int(input("What is your account number? \n"))

    is_vlid_account_number = validation.account_number_validation(
        accountNumberFromUser)

    if is_vlid_account_number:

        password = getpass("What is your password \n")

        user = database.authenticated_user(accountNumberFromUser, password)

        if user:
            database.login_auth_session(accountNumberFromUser, user)

        print('Invalid account or password')
        login()

    else:
        print(
            "Account Number Invalid: check that you have up to 10 digits and only numbers"
        )
        init()
Exemplo n.º 14
0
def login():
    print("**********'Please login in your account'**********")

    account_number_from_user = input("What is your account number?\n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password? \n")

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            bank_operation(user)

        #for account_number,user_details in database.items():
        #if account_number == account_number_from_user :
        #if user_details[3] == password:
        #bank_operation(user_details)

        print('Invalid account or password')
        login()
    else:
        print(
            "Account number invalid: Check that your have upto 10 digits and only numbers"
        )
        init()
def deposit():
    # get current balance
    # get amount to deposit
    # add deposited amount to current balance
    # display current balance
    current_user_account_number = int(input("Enter your account number: \n"))
    is_account_valid = validation.account_number_validation(
        current_user_account_number)
    if is_account_valid:
        current_user = str.split(database.read(current_user_account_number),
                                 ',')
        print("Your current account balance is " + "NGN" + current_user[4] +
              ".00")

        deposit_amount = int(input("Enter the amount you want to deposit: \n"))
        new_balance = int(current_user[4]) + deposit_amount
        # update user account balance
        # database.update(current_user_account_number, 4)
        print("Your new account balance is " + "NGN" + str(new_balance) +
              ".00 \n")
        print("Thank you for banking with us \n")
        exit()
    else:
        print("Invalid account number. Please try again")
        auth.login()
Exemplo n.º 16
0
def login():
    print("******* Login *******")

    account_number_from_user = (input("What is Your Account Number? \n"))
    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        # modifyiing password to appear encrypted
        # password = input('Input Your Password \n')
        password = getpass('What is Your Password \n')

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            bank_operation(user)

            # for account_number, user_details in database.items():
            #     if account_number == int(account_number_from_user):
            #         if user_details[3] == password:

        print('Invalid Account or Password')
        login()

    else:
        print("Account Number Invalid; ensure you have only integers!")
        init()
Exemplo n.º 17
0
def login():
    print("********* Login ***********")

    account_number_from_user = input("What is your account number?\n")
    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password?:\n")
        user = database.authenticated_user(account_number_from_user, password)
        if user:
            bank_operation(user, account_number_from_user)
        print("Invalid account or pin")
        login()
        user_session = database.start_auth(user[0])
        if user_session:
            # Start session
            database.start_auth(user)
            # End session
            database.end_auth(user)
        else:
            print('Invalid account or password')
            login()
    else:
        print(
            "Account Number Invalid: check that you have up to 10 digits and only integers."
        )
        welcome()
Exemplo n.º 18
0
def login():
    print("********* Login ***********")

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password \n")

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            bank_operation(user)

        print('Invalid account or password')
        login()

    else:
        print(
            "Account Number Invalid: check that you have up to 10 digits and only integers"
        )
        init()
Exemplo n.º 19
0
def read(user_account_number):

    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    try:

        if is_valid_account_number:
            f = open(user_db_path + str(user_account_number) + ".txt", "r")
        else:
            f = open(user_db_path + user_account_number, "r")

    except FileNotFoundError:

        print("User not found.")

    except FileExistsError:

        print("User already exists")

    except TypeError:

        print("Invalid account number format")

    else:

        return f.readline()

    return False
Exemplo n.º 20
0
def login():
    print("********* Login ***********")
    global account_number_from_user

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password? \n")

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            file = open("data/auth_session/session.txt", 'w+')
            file.close()
            bank_operation(user)

        else:
            print('Invalid account number or password')
            login()

    else:
        print(
            "Account Number Invalid: check that you have up to 10 digits and only integers"
        )
        init()
Exemplo n.º 21
0
def read(user_account_number):
    
    # find the user with the account number
    # fetch contents of the file 
    # return True
    
    is_valid_account_number = validation.account_number_validation(user_account_number)
    try:
        
        if(is_valid_account_number):
            f = open(user_db_path + str(user_account_number) + '.txt', 'r') # changed the x from the create function string to r because that is the read parameter
        else:
            f = open(user_db_path + user_account_number, 'r') 

    except FileNotFoundError:
        print('User not found')

    except FileExistsError:
        print("User doesn't exist")

    except TypeError:
        print('Invalid account number format')

    else: # else always comes after the exceptions 
        return f.readline()

    return False 
def login():
    accountNumber = input('To login enter account number. \n')
    
    is_valid_account_number = validation.account_number_validation(accountNumber)

    if is_valid_account_number:
        password = input(' Enter password \n')
        print('How can we help you today?')
        operations()
    else:
        print("invalid account number")
        login()
Exemplo n.º 23
0
def deposit_operation():

    print('Please enter recipient Account No: ')

    repAcc = input()
    print(repAcc)

    is_valid_repAcc = validation.account_number_validation(repAcc)

    if is_valid_repAcc:

        print('Please enter deposit amount in NGN')

        depAmt = int(input())
        print('Deposit NGN %s to %s?' % (depAmt, repAcc))
        print('1. Yes')
        print('2. No')

        doubleCheck = int(input())
        if (doubleCheck == 1):
            # balance += depAmt
            print('Transaction complete!')
            print('Your account balance is NGN %d' % depAmt)
            print('Thank you for using this service!')

        elif (doubleCheck == 2):
            print('Please select an option:')
            print('1. Perform another transaction?')
            print('2. Exit')

            anotherTrans = int(input())
            if (anotherTrans == 1):
                print(
                    'Please restart your transaction! Note to me: I need to rerun the ATM loop here'
                )

            elif (anotherTrans == 2):
                print('Thank you!')
                print('Please take your card!')

            else:
                print('Invalid option selected, please try again!')

        else:
            print('Invalid option selected, please try again!')

    else:
        print('Please check the number and try again!')
Exemplo n.º 24
0
def read(account_number):
    is_valid_account_number = validation.account_number_validation(
        account_number)
    if not is_valid_account_number:
        return False
    try:
        f = open(user_db_path + str(account_number) + ".txt", "r")

    except FileNotFoundError:
        print("User not found")
    except FileExistsError:

        print("User already exist")

    else:
        return f.readline()
def login():
    print("********* Login ***********")

    accountNumberFromUser = int(input("What is your account number? \n"))
    password = input("What is your password \n")
    account_number_from_user = input("What is your account number? \n")

    for accountNumber, userDetails in database.items():
        if (accountNumber == accountNumberFromUser):
            if (userDetails[3] == password):
                bankOperation(userDetails)

    print('Invalid account or password')
    login()

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)
Exemplo n.º 26
0
def login():

    print("****** Login ******")

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = input("What is your password? \n")

        user = database.authenticated_user(account_number_from_user, password)

        user_db_path_1 = 'data/auth_session/'

        # Creating a file in auth_session folder to keep track of user login

        try:

            f = open(user_db_path_1 + str(account_number_from_user) + ".txt",
                     "w+")
            f.write(str(user))
            f.close()

        except FileNotFoundError:

            print("User is not found.")

        except FileExistsError:

            print("User does not exist.")

        except TypeError:

            print(
                "Account number invalid: check that you have up to 10 digits and only integers."
            )

        else:
            bank_operations(user)
            login()

    init()
Exemplo n.º 27
0
def login():
    print("Login")

    account_number_from_user = input("What is your account number? \n")

    is_valid_account_number = validation.account_number_validation(
        account_number_from_user)

    if is_valid_account_number:

        password = getpass("What is your password \n")

        user = database.authenticated_user(account_number_from_user, password)

        if user:
            bank_operation(user)

        print('Invalid account or password')
        login()
Exemplo n.º 28
0
def login():
    print("******* LOGIN ******")
    userAccountNumber = int(input("What is your account number? \n"))
    #print(database[userAccountNumber])
    #password = input("What is your password? \n")
    isValidAccounntNumber = validation.account_number_validation (userAccountNumber)
    #print(isValidAccounntNumber)

    if isValidAccounntNumber:

        password = input("What is your password \n")
        if(password != database[userAccountNumber][-1]):
            print("Wrong password")
            login()
        else:
            bankOperation(database[userAccountNumber])
    else:
        print("Account Number Invalid: check that you have up to 10 digits and only integers")
        init()
Exemplo n.º 29
0
def read(user_account_number):
    print("Displaying User Records")
    is_valid_account_number = validation.account_number_validation(
        user_account_number)

    try:
        if is_valid_account_number:
            f = open(user_db_path + str(user_account_number) + ".txt", "r")
        else:
            f = open(user_db_path + user_account_number, "r")

    except FileExistsError:
        print("User doesn't exist")

    except FileNotFoundError:
        print("User Not Found")

    else:
        return f.readline()
    return False
Exemplo n.º 30
0
def login():
    print("*** Login into your Account ***")
    global accountNumberFromUser
    accountNumberFromUser = int(input("Enter your Account Number: "))

    is_valid_account_number = account_number_validation(accountNumberFromUser)

    if is_valid_account_number:
        password = getpass("Enter your password: "******"Invalid account or Password")
    else:
        print(
            "Account Number Invalid: check that you have up to number is 10 digits and only integers"
        )
        login()