コード例 #1
0
    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')
コード例 #2
0
ファイル: passwords.py プロジェクト: tdhris/HackBulgaria
def reset_password(username):
    user = sql_manager.get_client_by_username(username)
    user_email = user.get_email()
    user_id = user.get_id()

    changepass, code_generated = sql_manager.get_changepass_details(user_id)
    currenttime = int(time.time())
    five_minutes = 5 * 60

    code = input("Enter the code you received at {0}".format(
        user_email + ": "))
    if code == changepass and currenttime < code_generated + five_minutes:
        new_pass = getpass("Enter your new password: "******"Password Successfully Changed")
        else:
            print("Your password is not strong enough.")

        sql_manager.change_pass(new_pass, user)
    elif currenttime > code_generated + five_minutes:
        print("Sorry. You've entered a code that's no longer valid")
    else:
        print("Sorry, wrong code")
コード例 #3
0
    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')
コード例 #4
0
    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')
コード例 #5
0
ファイル: start.py プロジェクト: kazuohirai/HackBulgaria
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")
コード例 #6
0
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: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'deposit':
            deposit_sum = input("Enter the sum you want to deposit: ")
            sql_manager.deposit(deposit_sum)

        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")
            print("deposit - for depositing money in the bank account")
            print("withdraw - for withdrawing money from the bank account")
            print("balance - for displaying the current balance")
コード例 #7
0
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 = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")
コード例 #8
0
ファイル: start.py プロジェクト: gbalabanov/Hack_BG_101
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 = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")
コード例 #9
0
    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")
コード例 #10
0
    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')
コード例 #11
0
ファイル: start.py プロジェクト: kazuohirai/HackBulgaria
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":
            os.system("stty -echo")
            new_pass = input("Enter your new password: "******"stty echo")
            sql_manager.change_pass(new_pass, logged_user)

        elif command == "change-message":
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == "show-message":
            print(logged_user.get_message())

        elif command == "deposit":
            amount = float(input("Enter amount: "))
            otp_code = input("Enter OTP: ")
            available_otp = sql_manager.get_otp_for_user(logged_user.get_username())
            if otp_code in available_otp:
                logged_user.deposit(amount)
                sql_manager.remove_used_otp(logged_user.get_username(), otp_code)
                sql_manager.update_deposit(logged_user.get_username(), logged_user.get_balance())
                print("Deposit successful.")
            else:
                print("Deposit unsuccessful.")

        elif command == "withdraw":
            amount = float(input("Enter amount: "))
            otp_code = input("Enter OTP: ")
            available_otp = sql_manager.get_otp_for_user(logged_user.get_username())
            if otp_code in available_otp:
                sql_manager.remove_used_otp(logged_user.get_username(), otp_code)
                result = logged_user.withdraw(amount)
                if result == "Withdraw successful.":
                    print(result)
                    sql_manager.update_deposit(logged_user.get_username(), logged_user.get_balance())
                else:
                    print("Withdraw unsuccessful.")
            else:
                print("Withdraw unsuccessful.")

        elif command == "get-otp":
            sql_manager.get_otp(logged_user.get_username())

        elif command == "help":
            print("help - for showing this message")
            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")
コード例 #12
0
def logged_menu(logged_user):
    while True:
        print('''Hi, {}
                Now you have the following options:
                1) Info
                2) Change pass
                3) Show message
                4) Change message
                5) DEPOSIT MONEY
                6) WITHDRAW MONEY
                7) DISPLAY CURRENT BALANCE
                8) Help
                9) log out
                '''.format(logged_user.get_username()))
        choice = int(input("Choose an option: "))

        if choice == 1:
            os.system('clear')
            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 choice == 2:
            new_pass = getpass.getpass("Enter your new password: "******"Enter your new password again!: ")
            if new_pass == verify_pass and validate_pass(
                    new_pass, logged_user.get_username()):
                sql_manager.change_pass(new_pass, logged_user)
            else:
                print("Invalid password")
        elif choice == 3:
            os.system('clear')
            print(logged_user.get_message())
        elif choice == 4:
            os.system('clear')
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)
        elif choice == 5:
            amount = input("How much do you want to deposit?")
            sql_manager.deposit(amount, logged_user)
            print("You have successfully added {} $ to your account".format(
                amount))
        elif choice == 6:
            os.system('clear')
            amount = input("How much do you want to withdraw: ")
            if sql_manager.withdraw(amount):
                print("Here are your {} $".format(amount))
            else:
                print("You don't have that kind of money")
        elif choice == 7:
            os.system('clear')
            print("Your balance is:" + str(logged_user.get_balance()) + '$')
        elif choice == 8:
            print('''Info - for showing account info
            Change pass - for changing passowrd
            Change message - for changing users message
            Show message - for showing users message
            ''')
        elif choice == 9:
            break
コード例 #13
0
    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"))
コード例 #14
0
    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"))
コード例 #15
0
 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])
コード例 #16
0
ファイル: start.py プロジェクト: VasilVasilev93/HackBulgaria
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(prompt='Password: '******'deposit':
            amount = input("Enter amount: ")
            tan_code = input("Enter your TAN code: ")
            if sql_manager.use_tan(logged_user, tan_code):
                if logged_user.deposit(float(amount)):
                    new_balance = logged_user.get_balance()
                    sql_manager.deposit(logged_user, new_balance)
                    print("Deposited %s$ succesfully." % amount)

        elif command == 'withdraw':
            amount = input("Enter amount: ")
            tan_code = input("Enter your TAN code: ")
            if sql_manager.use_tan(logged_user, tan_code):
                if logged_user.withdraw(float(amount)):
                    new_balance = logged_user.get_balance()
                    sql_manager.withdraw(logged_user, new_balance)
                    print("Withdrew %s$ succesfully." % amount)

        elif command == 'get-tan':
            password = getpass.getpass(prompt='Enter your password again please: ')
            if sql_manager.validate_password(logged_user, password):
                sql_manager.get_tan(logged_user)
            else:
                print("Invalid password.")

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'logout':
            print("Goodbye %s!" % logged_user.get_username())
            break

        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")
コード例 #17
0
def change_pass(logged_user):
    smtp_handler.send_reset_code(logged_user.get_username())
    received_code = input("The code you received: ")
    if sql_manager.get_reset_code(logged_user.get_username()) == received_code:
        new_pass = getpass("Enter your new password: "******"sha1")
            sql_manager.change_pass(new_pass, logged_user)
        else:
            print("Your new password sucks. Think of a better one!")
    else:
        print("The entered code isn't valid.")
コード例 #18
0
    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])
コード例 #19
0
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: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'deposit':
            amount = input("Enter the amount of money you want to deposit: ")
            tan = input("Enter TAN code: ")
            sql_manager.deposit(amount, tan, logged_user)

        elif command == 'withdraw':
            amount = input("Enter the amount of money you want to withdraw: ")
            tan = input("Enter TAN code: ")
            sql_manager.withdraw(amount, tan, logged_user)

        elif command == 'display-balance':
            print(sql_manager.display_balance(logged_user))

        elif command == 'get-tan':
            sql_manager.get_tan(logged_user)

        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")
            print("deposit - to deposit into your account")
            print("withdraw - to withdraw from your account")
            print("display-balance - to display your current balance")
            print("get-tan - to send TAN codes to your email, you need " \
                  "them to make a deposit or to withdraw!")
            print("logout - to return to the main menu")

        elif command == 'logout':
            break
コード例 #20
0
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>").split(" ")

        if command[0] == '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[0] == 'changepass':
            new_pass = getpass.getpass("Enter your new password: "******"Password is not strong enough!")
                new_pass = getpass.getpass("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command[0] == 'show-message':
            print(logged_user.get_message())

        elif command[0] == "deposit" and len(command) > 1 and command[1].isdecimal():
            amount = int(command[1])
            sql_manager.deposit(logged_user.get_username(), amount)
            logged_user.deposit(amount)

        elif command[0] == "withdraw" and len(command) > 1 and command[1].isdecimal():
            amount = int(command[1])
            if amount >  logged_user.get_balance():
                print("Insufficient funds")
            else:
                logged_user.withdraw(amount)
                sql_manager.withdraw(logged_user.get_username(), amount)

        elif command[0] == "display-balance":
            print("Balance: {}".format(logged_user.get_balance()))

        elif command[0] == "logout":
            break

        elif command[0] == '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")
            print("deposit <amount> - deposits <amount>")
            print("withdraw <amount> - withdraws <amount>")
            print("display-balance - displays balance")
            print("logout - to logout")
コード例 #21
0
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-message":
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == "show-message":
            print(logged_user.get_message())

        elif command == "deposit":
            amount = input("Enter the amount of money you want to deposit: ")
            tan = input("Enter TAN code: ")
            sql_manager.deposit(amount, tan, logged_user)

        elif command == "withdraw":
            amount = input("Enter the amount of money you want to withdraw: ")
            tan = input("Enter TAN code: ")
            sql_manager.withdraw(amount, tan, logged_user)

        elif command == "display-balance":
            print(sql_manager.display_balance(logged_user))

        elif command == "get-tan":
            sql_manager.get_tan(logged_user)

        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")
            print("deposit - to deposit into your account")
            print("withdraw - to withdraw from your account")
            print("display-balance - to display your current balance")
            print("get-tan - to send TAN codes to your email, you need " "them to make a deposit or to withdraw!")
            print("logout - to return to the main menu")

        elif command == "logout":
            break
コード例 #22
0
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()
            sql_manager.change_pass(new_pass, logged_user)

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")

        elif command == 'deposit':
            amount = input('Enter amount: ')
            tan = input('Enter code: ')
            print(sql_manager.deposit(logged_user.get_username(), amount, tan))

        elif command == 'withdraw':
            amount = input('Enter amount: ')
            tan = input('Enter code: ')
            print(sql_manager.withdraw(logged_user.get_username(), amount.tan))

        elif command == 'display':
            print(sql_manager.get_balance(logged_user.get_username()))

        elif command == 'get-tan':
            password = getpass.getpass()
            print(
                sql_manager.generate_tan_codes(logged_user.get_username(),
                                               password))

        else:
            print("Not a valid command")
コード例 #23
0
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("Enter your new password: "******"Password should contain an upper and",
                        "a lowercase letter, a digit and a symbol"))
                new_pass = getpass("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)
        
        elif command == 'show-message':
            print(logged_user.get_message())

        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")
コード例 #24
0
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()
            sql_manager.change_pass(new_pass, logged_user)

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")

        elif command == 'deposit':
            amount = input('Enter amount: ')
            tan = input('Enter code: ')
            print(sql_manager.deposit(logged_user.get_username(), amount, tan))

        elif command == 'withdraw':
            amount = input('Enter amount: ')
            tan = input('Enter code: ')
            print(sql_manager.withdraw(logged_user.get_username(), amount. tan))

        elif command == 'display':
            print(sql_manager.get_balance(logged_user.get_username()))

        elif command == 'get-tan':
            password = getpass.getpass()
            print(sql_manager.generate_tan_codes(logged_user.get_username(), password))

        else:
            print("Not a valid command")
コード例 #25
0
ファイル: start.py プロジェクト: georgi-lyubenov/HackBulgaria
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: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)
        elif command == 'show-message':
            print(logged_user.get_message())
        elif command == 'deposit':
            amount = input("amount>")
            sql_manager.deposit(logged_user.get_username(), amount)
        elif command == 'withdraw':
            amount = input("amount>")
            sql_manager.withdraw(logged_user.get_username(), amount)
        elif command == 'balance':
            print(sql_manager.balance(str(logged_user.get_username())))
        elif command == 'show clients':
            sql_manager.show_clients()

        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")
            print("deposit - for depositting money")
            print("withdraw - for withdrowing money")
            print("balance - for showing balance")
コード例 #26
0
ファイル: start.py プロジェクト: georgi-lyubenov/HackBulgaria
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: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)
        elif command == 'show-message':
            print(logged_user.get_message())
        elif command == 'deposit':
            amount = input("amount>")
            sql_manager.deposit(logged_user.get_username(), amount)
        elif command == 'withdraw':
            amount = input("amount>")
            sql_manager.withdraw(logged_user.get_username(), amount)
        elif command == 'balance':
            print(sql_manager.balance(str(logged_user.get_username())))
        elif command == 'show clients':
            sql_manager.show_clients()

        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")
            print("deposit - for depositting money")
            print("withdraw - for withdrowing money")
            print("balance - for showing balance")
コード例 #27
0
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 = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")
            print("display - for display current balance")
            print("deposit - for deposit money")
            print("withdraw - for withdraw money")
        elif command == 'deposit':
            money = input("Enter amount: ")
            sql_manager.deposit_money(money, logged_user)
            print("Transaction successful!")
        elif command == 'display':
            sql_manager.display_money(logged_user)
        elif command == 'withdraw':
            money = input("Enter amount: ")
            sql_manager.withdraw_money(logged_user, money)
コード例 #28
0
ファイル: start.py プロジェクト: kal0ian/HackBulgaria
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 = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        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")
            print("display - for display current balance")
            print("deposit - for deposit money")
            print("withdraw - for withdraw money")
        elif command == 'deposit':
            money = input("Enter amount: ")
            sql_manager.deposit_money(money, logged_user)
            print("Transaction successful!")
        elif command == 'display':
            sql_manager.display_money(logged_user)
        elif command == 'withdraw':
            money = input("Enter amount: ")
            sql_manager.withdraw_money(logged_user, money)
コード例 #29
0
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(prompt="Enter your password: "******"info - for showing account info")
            print("changepass - for changing passowrd")

        elif command == 'logout':
            print("You have logged out!")
            break
        else:
            print("Not a valid command")
コード例 #30
0
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(prompt="Enter your password: "******"info - for showing account info")
            print("changepass - for changing passowrd")

        elif command == 'logout':
            print("You have logged out!")
            break
        else:
            print("Not a valid command")
コード例 #31
0
ファイル: start.py プロジェクト: kobso1245/Programming101-v3
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_info()
        elif command == 'changepass':
            new_pass = input("Enter your new password: "******"Password changed sucessfully!!")
            else:
                print(inp['reason'])
        elif command == 'reset-password':
            wrapped_reset_password(logged_user)
        elif command == 'set-email':
            mail = input("Please enter your email: ")
            set_email(logged_user.get_username(), mail)

        elif command == 'show-email':
            print(show_email(logged_user.get_username()))

        elif command == 'show-balance':
            print("Current balance is: {}".format(get_balance(logged_user.get_username())))

        elif command == 'withdraw':
            wrapped_withdraw(logged_user)
        elif command == 'deposit':
            wrapped_deposit(logged_user)

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == "logout":
            return

        elif command == 'help':
            print_all_commands()
コード例 #32
0
ファイル: start.py プロジェクト: kobso1245/Hack_BG
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_info()
        elif command == 'changepass':
            new_pass = input("Enter your new password: "******"Password changed sucessfully!!")
            else:
                print(inp['reason'])
        elif command == 'reset-password':
            wrapped_reset_password(logged_user)
        elif command == 'set-email':
            mail = input("Please enter your email: ")
            set_email(logged_user.get_username(), mail)

        elif command == 'show-email':
            print(show_email(logged_user.get_username()))

        elif command == 'show-balance':
            print("Current balance is: {}".format(
                get_balance(logged_user.get_username())))

        elif command == 'withdraw':
            wrapped_withdraw(logged_user)
        elif command == 'deposit':
            wrapped_deposit(logged_user)

        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == "logout":
            return

        elif command == 'help':
            print_all_commands()
コード例 #33
0
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        command = input("Logged>>")
        #command = 'get-tan'
        username = logged_user.get_username()

        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 = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'deposit':
            money = int(input('Enter amount:'))
            tan = input('Enter TAN code:')
            if tan in sql_manager.get_user_unused_tans(username):
                sql_manager.deposit(username, money)
                print('Transaction successful!')
                print('{} were deposited to the bank'.format(money))
                sql_manager.mark_tan_as_used(tan)
            else:
                print('Wrong TAN code!')

        elif command == 'withdraw':
            money = int(input('Enter amount:'))
            tan = input('Enter TAN code:')
            if tan in sql_manager.get_user_unused_tans(username):
                if sql_manager.withdraw(username, money):
                    print('Transaction successful!')
                    print('{} were withdrawed from the bank'.format(money))
                else:
                    print('Withdraw failed. Not enough money!')
                sql_manager.mark_tan_as_used(tan)
            else:
                print('Wrong TAN code!')

        elif command == 'display_balance':
            print('You have {} $ in your account'.format(
                logged_user.get_balance()))

        elif command == 'get-tan':
            unused_tans = sql_manager.get_user_unused_tans(username)
            if unused_tans:
                print('You have {} remaining TAN codes to use!'.format(
                    len(unused_tans)))
            else:
                password_correct = False
                while not password_correct:
                    password = getpass.getpass()
                    password_correct = sql_manager.is_password_correct(
                        username, password)
                    if not password_correct:
                        print('Incorrect password!')
                tans = sql_manager.generate_tans(username)
                desc_msg = 'You can use these 10 TANS in order to perform a transaction:'
                tans.insert(0, desc_msg)
                message = '\n'.join(tans)
                subject = 'TAN codes'
                send_email(username, subject, message)

        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")
コード例 #34
0
 def test_weak_password(self):
     logged_user = sql_manager.login('Tester', '123')
     new_password = "******"
     self.assertEqual(sql_manager.change_pass(new_password, logged_user),
                      None)
コード例 #35
0
def change_pass(logged_user):
    new_pass = input(INP_STR_CHANGE_PASS)
    sql_manager.change_pass(new_pass, logged_user)
コード例 #36
0
 def changepass(self):
     new_pass = input("Enter your new password: ")
     sql_manager.change_pass(new_pass, self.__user)
コード例 #37
0
ファイル: start.py プロジェクト: fyllmax/Programming101
def logged_menu(logged_user):
    print("Welcome you are logged in as: " + logged_user.get_username())
    while True:
        print("")
        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()) + '$')
            print("You have left with {} tan codes".format(logged_user.tan_left()))
            # print("Your email is:" + logged_user.get_email())

        elif command == 'changepass':
            new_pass = input("Enter your new password: "******"Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == 'help':
            help_command = [
                "List of commands:",
                "",
                "*info - for showing account info",
                "*changepass - for changing passowrd",
                "*change-message - for changing users message",
                "*show-message - for showing users message",
                "*deposit - putting funds in your bank acc",
                "*withdraw - getting funds out of your bank acc",
                "*balance - showing current available funds",
                "*get_tan - sends email with 10 tan codes needed for transaction"]

            print('\n'.join(help_command))

        elif command == 'get_tan':
            print(logged_user.get_tan())

        elif command == 'deposit':
            print(logged_user.deposit())

        elif command == 'withdraw':
            print(logged_user.withdraw())

        elif command == 'balance':
            print(logged_user.get_balance())

        elif command == 'exit':

            sql_manager.update_balance(logged_user.get_username(), logged_user.get_balance())

            if logged_user.check_tanlist_empty():
                print("You had 0 tan codes, so we send you new ones.")
                print(logged_user.get_new_tan())

            sql_manager.update_tan(logged_user.get_username(), logged_user.get_left_tans())

            break

        else:
            print('Not a valid command, try again!')
コード例 #38
0
 def test_weak_password(self):
     logged_user = sql_manager.login('Tester', '123')
     new_password = "******"
     self.assertEqual(sql_manager.change_pass(new_password, logged_user), None)
コード例 #39
0
    def test_change_password_pass_numb(self):
        logged_user = sql_manager.login('Tester', '123qwe@AS')
        new_password = "******"
        reg_success = sql_manager.change_pass(new_password, logged_user)

        self.assertEqual(True, reg_success)
コード例 #40
0
ファイル: passwords.py プロジェクト: tdhris/HackBulgaria
def change_password(logged_user):
    new_pass = getpass("Enter your new password: ")
    sql_manager.change_pass(new_pass, logged_user)
    print('Password Successfully Changed')
コード例 #41
0
    def test_change_password_wrong_1(self):
        logged_user = sql_manager.login('Tester', '123qwe@AS')
        new_password = "******"
        reg_success = sql_manager.change_pass(new_password, logged_user)

        self.assertEqual(False, reg_success)
コード例 #42
0
    def test_change_password_wrong_1(self):
        logged_user = sql_manager.login('Tester', '123qwe@AS')
        new_password = "******"
        reg_success = sql_manager.change_pass(new_password, logged_user)

        self.assertEqual(False, reg_success)
コード例 #43
0
    def test_change_password_pass_numb(self):
        logged_user = sql_manager.login('Tester', '123qwe@AS')
        new_password = "******"
        reg_success = sql_manager.change_pass(new_password, logged_user)

        self.assertEqual(True, reg_success)
コード例 #44
0
 def test_change_password_invalid(self):
     logged_user = sql_manager.login("Tester", "12asER>?_")
     new_password = "******"
     result = sql_manager.change_pass(new_password, logged_user)
     self.assertEqual(result, "Please enter a valid password.")
コード例 #45
0
ファイル: start.py プロジェクト: mihail-nikolov/hackBG
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':
            username = logged_user.get_username()
            mess_hash_code = sql_manager.get_hashcode()
            mailed_code = sql_manager.send_mail_user(username, mess_hash_code)
            print("We have just sent you an email with hashcode\
                \n To let you to change your password we have to\
                \n make sure that you are the owner of the email.\
                \n type the hash code here:")
            entered_hash = input("hash code: ")
            if sql_manager.check_password(mailed_code, entered_hash):
                new_pass = pass_conditions(username)
                new_hashed_pass = hash_password(new_pass)
                sql_manager.change_pass(new_hashed_pass, logged_user)
                print("Password changing Successfull")
            else:
                print("Sorry the hash code is wrong. Try again!")
        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == "withdraw":
            username = logged_user.get_username()
            money = int(input("type money: "))
            balance = sql_manager.get_balance(username)
            if money > balance:
                print("you do not have enough money")
            else:
                input_TAN = input("type TAN: ")
                if sql_manager.is_TAN_usable(username) is False:
                    print("You have to get new TAN")
                elif sql_manager.is_curr_TAN(username, input_TAN) is False:
                    print("Input a valid TAN")
                else:
                    sql_manager.withdraw_money(username, money)
                    sql_manager.increase_TAN_counter(username)
                    print("You have Successfully withdrawed money")

        elif command == "deposit":
            username = logged_user.get_username()
            money = int(input("type money: "))
            input_TAN = input("type TAN: ")
            if sql_manager.is_TAN_usable(username) is False:
                print("You have to get new TAN")
            elif sql_manager.is_curr_TAN(username, input_TAN) is False:
                print("Input a valid TAN")
            else:
                sql_manager.deposit_money(username, money)
                sql_manager.increase_TAN_counter(username)
                print("You have Successfully deposited money")

        elif command == "get-tan":
            username = logged_user.get_username()
            new_TAN = sql_manager.get_ran_str()

            while sql_manager.is_TAN_used(username, new_TAN) is True:
                new_TAN = sql_manager.get_ran_str()
            sql_manager.make_TAN_changes(username, new_TAN)
            sql_manager.send_mail_user(username, new_TAN)
            print('We have sent you email with your new TAN')

        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")
            print("withdraw - withdraw money")
            print("deposit - deposit money")
            print("get-tan - calculating new TAN")
コード例 #46
0
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")
コード例 #47
0
def changepass(logged_user):
    new_pass = input("Enter your new password: ")
    sql_manager.change_pass(new_pass, logged_user)
コード例 #48
0
 def test_change_password_valid(self):
     logged_user = sql_manager.login("Tester", "12asER>?_")
     new_password = "******"
     result = sql_manager.change_pass(new_password, logged_user)
     self.assertEqual(result, "Password updated.")
コード例 #49
0
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':
            username = logged_user.get_username()
            mess_hash_code = sql_manager.get_hashcode()
            mailed_code = sql_manager.send_mail_user(username, mess_hash_code)
            print("We have just sent you an email with hashcode\
                \n To let you to change your password we have to\
                \n make sure that you are the owner of the email.\
                \n type the hash code here:")
            entered_hash = input("hash code: ")
            if sql_manager.check_password(mailed_code, entered_hash):
                new_pass = pass_conditions(username)
                new_hashed_pass = hash_password(new_pass)
                sql_manager.change_pass(new_hashed_pass, logged_user)
                print("Password changing Successfull")
            else:
                print("Sorry the hash code is wrong. Try again!")
        elif command == 'change-message':
            new_message = input("Enter your new message: ")
            sql_manager.change_message(new_message, logged_user)

        elif command == 'show-message':
            print(logged_user.get_message())

        elif command == "withdraw":
            username = logged_user.get_username()
            money = int(input("type money: "))
            balance = sql_manager.get_balance(username)
            if money > balance:
                print("you do not have enough money")
            else:
                input_TAN = input("type TAN: ")
                if sql_manager.is_TAN_usable(username) is False:
                    print("You have to get new TAN")
                elif sql_manager.is_curr_TAN(username, input_TAN) is False:
                    print("Input a valid TAN")
                else:
                    sql_manager.withdraw_money(username, money)
                    sql_manager.increase_TAN_counter(username)
                    print("You have Successfully withdrawed money")

        elif command == "deposit":
            username = logged_user.get_username()
            money = int(input("type money: "))
            input_TAN = input("type TAN: ")
            if sql_manager.is_TAN_usable(username) is False:
                print("You have to get new TAN")
            elif sql_manager.is_curr_TAN(username, input_TAN) is False:
                print("Input a valid TAN")
            else:
                sql_manager.deposit_money(username, money)
                sql_manager.increase_TAN_counter(username)
                print("You have Successfully deposited money")

        elif command == "get-tan":
            username = logged_user.get_username()
            new_TAN = sql_manager.get_ran_str()

            while sql_manager.is_TAN_used(username, new_TAN) is True:
                new_TAN = sql_manager.get_ran_str()
            sql_manager.make_TAN_changes(username, new_TAN)
            sql_manager.send_mail_user(username, new_TAN)
            print('We have sent you email with your new TAN')

        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")
            print("withdraw - withdraw money")
            print("deposit - deposit money")
            print("get-tan - calculating new TAN")