• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sql_manager.change_pass函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sql_manager.change_pass函数的典型用法代码示例。如果您正苦于以下问题:Python change_pass函数的具体用法?Python change_pass怎么用?Python change_pass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了change_pass函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main_menu

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: ")
            os.system("stty -echo")
            password = input("Enter your password: ")
            os.system("stty echo")
            email = input("Enter your email address: ")

            print(sql_manager.register(username, password, email))

        elif command[0] == "login":
            username = input("Enter your username: ")
            os.system("stty -echo")
            password = input("Enter your password: ")
            os.system("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: ")
                os.system("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: ")
                    os.system("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")
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:60,代码来源:start.py


示例2: test_change_password

    def test_change_password(self):
        logged_user = sql_manager.login('Tester', 'asdaFGG45g*&')
        new_password = "mvxza23g5g!~"
        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')
开发者ID:nkolchakov,项目名称:Programming101-Python,代码行数:7,代码来源:sql_manager_test.py


示例3: reset_password

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

        if sql_manager.strong_password(username, new_pass):
            sql_manager.change_pass(new_pass, user)
            print("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")
开发者ID:tdhris,项目名称:HackBulgaria,代码行数:25,代码来源:passwords.py


示例4: test_change_password

    def test_change_password(self):
        logged_user = sql_manager.login("Tester", STRONG_PASSWORD1)
        new_password = "12345"
        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")
开发者ID:VikiDinkova,项目名称:HackBulgaria,代码行数:7,代码来源:sql_manager_test.py


示例5: logged_menu

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: ")
            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")
开发者ID:gbalabanov,项目名称:Hack_BG_101,代码行数:26,代码来源:start.py


示例6: logged_menu

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: ")
            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':
            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")
开发者ID:polinakrusteva,项目名称:Programming101-Python,代码行数:33,代码来源:start.py


示例7: logged_menu

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: ")
            os.system("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")
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:59,代码来源:start.py


示例8: test_change_password_with_sql_injection

    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 = "1234Asdf$$$Asdf' WHERE id = 3 --"
        sql_manager.change_pass(new_password, logged_user)
        self.assertFalse(sql_manager.login('Vladko', "1234Asdf$$$Asdf"))
开发者ID:Martin95056,项目名称:HackBulgaria,代码行数:8,代码来源:sql_manager_test.py


示例9: test_change_pass

 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])
开发者ID:SvetlaGeorgieva,项目名称:HackBulgaria-Programming101,代码行数:10,代码来源:test_start.py


示例10: logged_menu

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: ')
            sql_manager.change_pass(new_pass, logged_user)

        elif command == '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")
开发者ID:VasilVasilev93,项目名称:HackBulgaria,代码行数:55,代码来源:start.py


示例11: logged_menu

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: ")
            while not sql_manager.is_strong(logged_user.get_username(), new_pass):
                print("Password is not strong enough!")
                new_pass = getpass.getpass("Enter your new password: ")
            sql_manager.change_pass(new_pass, logged_user)

        elif command[0] == 'change-message':
            new_message = input("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")
开发者ID:nkgeorgiev,项目名称:HackBulgaria---Programming101---2,代码行数:51,代码来源:start.py


示例12: logged_menu

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: ")
            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 = 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
开发者ID:EmilianStankov,项目名称:Money-In-The-Bank,代码行数:50,代码来源:start.py


示例13: logged_menu

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")
开发者ID:Dayana-Marinova,项目名称:HackBulgariaHomework,代码行数:46,代码来源:start.py


示例14: logged_menu

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: ")
            hash_object = hashlib.sha1(new_pass.encode()).digest()
            sql_manager.change_pass(str(hash_object), logged_user.get_username())

        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 = 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")
开发者ID:georgi-lyubenov,项目名称:HackBulgaria,代码行数:39,代码来源:start.py


示例15: logged_menu

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: ")
            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")
            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)
开发者ID:kal0ian,项目名称:HackBulgaria,代码行数:38,代码来源:start.py


示例16: logged_menu

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: ", stream=None)
            sql_manager.change_pass(new_pass, logged_user)

        elif command == 'help':
            print("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")
开发者ID:SvetlaGeorgieva,项目名称:HackBulgaria-Programming101,代码行数:24,代码来源:start.py


示例17: logged_menu

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: ")
            inp = sql_manager.change_pass(new_pass, logged_user)
            if inp == True:
                print("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()
开发者ID:kobso1245,项目名称:Programming101-v3,代码行数:44,代码来源:start.py


示例18: test_change_password_invalid

 def test_change_password_invalid(self):
     logged_user = sql_manager.login("Tester", "12asER>?_")
     new_password = "123"
     result = sql_manager.change_pass(new_password, logged_user)
     self.assertEqual(result, "Please enter a valid password.")
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:5,代码来源:sql_manager_test.py


示例19: test_weak_password

 def test_weak_password(self):
     logged_user = sql_manager.login('Tester', '123')
     new_password = "12345"
     self.assertEqual(sql_manager.change_pass(new_password, logged_user), None)
开发者ID:georgi-lyubenov,项目名称:HackBulgaria,代码行数:4,代码来源:sql_manager_test.py


示例20: change_password

def change_password(logged_user):
    new_pass = getpass("Enter your new password: ")
    sql_manager.change_pass(new_pass, logged_user)
    print('Password Successfully Changed')
开发者ID:tdhris,项目名称:HackBulgaria,代码行数:4,代码来源:passwords.py



注:本文中的sql_manager.change_pass函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sql_manager.login函数代码示例发布时间:2022-05-27
下一篇:
Python sql.Table类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap