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

Python sql_manager.login函数代码示例

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

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



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

示例1: 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


示例2: test_login_wrong_password_5_in_row

 def test_login_wrong_password_5_in_row(self):
     logged_user = sql_manager.login('Tester', '123567')
     logged_user = sql_manager.login('Tester', '123567')
     logged_user = sql_manager.login('Tester', '123567')
     logged_user = sql_manager.login('Tester', '123567')
     logged_user = sql_manager.login('Tester', '123567')
     self.assertFalse(logged_user)
开发者ID:dsspasov,项目名称:HackBulgaria,代码行数:7,代码来源:sql_manager_test.py


示例3: 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


示例4: 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


示例5: 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


示例6: login

def login():
        username = input("Enter your username: ")
        password = input("Enter your password: ")
        try:
            sql_manager.login(username, password)
            logged_menu(username)
        except UnsuccessfulLoginException as e:
            print(e)
开发者ID:whisper95,项目名称:Programming-with-python-101,代码行数:8,代码来源:start.py


示例7: test_login

    def test_login(self):
        logged_user = sql_manager.login('Tester', '[email protected]')
        self.assertEqual(logged_user.get_username(), 'Tester')


        logged_user = sql_manager.login('\' OR 1==1--', '123')
        self.assertFalse(logged_user)

        logged_user = sql_manager.login('Blq', '\' OR 1==1--')
        self.assertEqual(False,logged_user)
开发者ID:mimipaskova,项目名称:HackBulgaria-Programming101,代码行数:10,代码来源:sql_manager_test.py


示例8: main_menu

def main_menu():
    print("Welcome to our bank service. You are not logged in. \nPlease register or login")

    while True:
        command = input("$$$>")

        if command == 'register':
            result = print_username_password()
            username = result['username']
            password = result['password']
            inp = sql_manager.register(username, password)
            if inp == True:
                print("Registration Successfull")
            else:
                print(inp['reason'])
        elif command == 'login':
            result = print_username_password()
            username = result['username']
            password = result['password']

            logged_user = sql_manager.login(username, password)

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")

        elif command == 'help':
            print_help()
        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:kobso1245,项目名称:Programming101-v3,代码行数:33,代码来源:start.py


示例9: main_menu

def main_menu():
    print("Welcome to our bank service. You are not logged in. \nPlease register or login")

    while True:
        command = input("$$$>")

        if command == 'register':
            username = input("Enter your username: ")
            password = valid_password()

            sql_manager.register(username, password)

            print("Registration Successfull")

        elif command == 'login':
            username = input("Enter your username: ")
            password = input("Enter your password: ")

            logged_user = sql_manager.login(username, password)

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")

        elif command == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("exit - for closing program!")

        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:NikiMaslarski,项目名称:HackBulgari_Programming101,代码行数:34,代码来源:start.py


示例10: start

    def start(self):
        print(messages.WELCOME_MSG)
        while True:
            command = input("$$$>")

            if command == 'register':
                username = input("Enter your username: ")
                password = input("Enter your password: ")
                try:
                    sql_manager.register(username, password)
                    print(messages.SUCCESSFUL_REG_MSG)
                except PasswordNotStrongError:
                    print(messages.STRONG_PASSWORD_ERROR_MSG)

            elif command == 'login':
                username = input("Enter your username: ")
                password = getpass.getpass("Enter your password: ")
                logged_user = sql_manager.login(username, password)

                if logged_user:
                    self.logged_menu(logged_user)
                else:
                    print(messages.LOGIN_FAIL_MSG)

            elif command == 'help':
                print("login - for logging in!")
                print("register - for creating new account!")
                print("exit - for closing program!")

            elif command == 'exit':
                break
            else:
                print("Not a valid command")
开发者ID:Martin95056,项目名称:HackBulgaria,代码行数:33,代码来源:cli.py


示例11: main_menu

def main_menu(conn, cursor):
    print("Welcome to our bank service. You are not logged in. \nPlease register or login")
    while True:
        command = input("$$$>")
        if command == 'register':
            username = input("Enter a username: ")
            password = getpass.getpass(prompt="Enter a password: ")
            while not sql_manager.password_validation(username, password):
                password = getpass.getpass(prompt="Enter a password again: ")
                print("WEAK password")
            sql_manager.register(conn, cursor, username, password)

            print("Registration Successfull")
        elif command == 'login':
            count_wrong_input = 0
            username = input("Enter your username: ")
            password = ""
            while not sql_manager.login(conn, cursor, username, password):
                password = getpass.getpass(prompt="Enter your password: ")
                count_wrong_input += 1
                if count_wrong_input < 5:
                    continue
                else:
                    print("You entered wrong password 5 times!")
                    boom = 30
                    while boom >= 0:
                        time.sleep(1)
                        print("You can enter you password again after:{}sec".format(boom), end='\r')
                        boom -= 1
                    count_wrong_input = 0
            logged_user = sql_manager.login(conn, cursor, username, password)

            if logged_user:
                logged_menu(conn, cursor, logged_user)
            else:
                print("Login failed")
        
        elif command == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("exit - for closing program!")

        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:AntonioFilipov,项目名称:HackBulgaria-Programming101,代码行数:46,代码来源:start.py


示例12: main_menu

def main_menu():
    failed_log_users = [1]
    fail_log_counter = 0
    wrong_pass_limit = 5
    block_message = "you have 5 wrong password inputs\
                    \n and you`re blocked for 5 minutes"

    print("Welcome to our bank service. You are not logged in.\
          \nPlease register or login")

    while True:
        command = input("$$$>")
        if command == 'register':
            username = input("Enter your username: ")
            password = pass_conditions(username)
            hashed_pass = hash_password(password)
            email = input("Enter your emal: ")
            sql_manager.register(username, hashed_pass, email)

            print("Registration Successfull")

        elif command == 'login':
            username = input("Enter your username: ")
            password = getpass.getpass('Password:')
            input_pass = hash_password(password)

            logged_user = sql_manager.login(username)
            existing_pass = sql_manager.get_user_pass(username)
            is_pass_eq = sql_manager.check_password(input_pass, existing_pass) is True
            if logged_user and is_pass_eq and can_login(username) is True:
                fail_log_counter = 0
                sql_manager.unbclock_user(username)
                logged_menu(logged_user)
                failed_log_users = [1]
            else:
                print("Login failed")
                last_user = failed_log_users[len(failed_log_users) - 1]
                if fail_log_counter >= wrong_pass_limit:
                    print(block_message)
                if username == last_user:
                    fail_log_counter += 1
                    if fail_log_counter == wrong_pass_limit:
                        sql_manager.block_user(username)
                        fail_log_counter = 0
                        print(block_message)
                else:
                    fail_log_counter = 1
                failed_log_users.append(username)

        elif command == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("exit - for closing program!")

        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:mihail-nikolov,项目名称:hackBG,代码行数:58,代码来源:start.py


示例13: 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: ")
            password = getpass.getpass("Enter your password: ")
            while not sql_manager.is_strong(username, password):
                print("Password is not strong enough!")
                password = getpass.getpass("Enter your password: ")
            email = input("Enter your email: ")
            sql_manager.register(username, password, email)

            print("Registration Successfull")

        elif command[0] == 'login':
            username = input("Enter your username: ")
            password = getpass.getpass("Enter your password: ")

            logged_user = sql_manager.login(username, password)

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")

        elif command[0] == "reset-password" and len(command) >1:
            reset_hash = hashlib.sha1(str(random.random()).encode()).hexdigest()
            sql_manager.update_reset_hash(command[1], reset_hash)
            send_email.send_email(sql_manager.get_email(command[1]), reset_hash)
            print(command[1])


        elif command[0] == "send-reset-password" and len(command) > 1:
            reset_hash = input("Enter reset hash: ")
            if reset_hash == sql_manager.get_reset_hash(command[1]):
                logged_user = sql_manager.login_with_hash(command[1], reset_hash)
                if logged_user:
                    logged_menu(logged_user)
                else:
                    print("Login failed")


        elif command[0] == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("exit - for closing program!")
            print("reset-password <name> - to reset password")
            print("send-reset-password <name> - to enter reset password")

        elif command[0] == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:nkgeorgiev,项目名称:HackBulgaria---Programming101---2,代码行数:56,代码来源:start.py


示例14: 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


示例15: login

    def login(cls):
        username = input("Enter your username: ")
        password = getpass.getpass(stream=None)

        logged_user = sql_manager.login(username, password)

        if logged_user:
            cls.logged_menu(logged_user)
        else:
            print("Login failed")

        return username
开发者ID:slaviana88,项目名称:Programming101-3,代码行数:12,代码来源:commands.py


示例16: main_menu

def main_menu():
    print("Welcome to our bank service. You are not logged in. \nPlease register or login")

    while True:
        command = input("$$$>")
        command_array = command.split(" ")
        if command == 'register':
            username = input("Enter your username: ")
            email = input('Enter your email: ')
            while True:
                password = getpass.getpass()
                if len(password) < 8:
                    print("Your Pasword is to short, it must be 8 symbols")
                elif not have_upper_letters(password):
                    print("Your password must have upper letters")
                elif not number_function(password):
                    print("Your password must have numbers")
                elif not have_special(password):
                    print("It must have special symbols")
                elif username in password:
                    print("Don`t use your name in your password")
                else:
                    sql_manager.register(username, sql_manager.get_crypted(password), email)
                    break
            print("Registration Successfull")

        elif command == 'login':
            username = input("Enter your username: ")

            logged_user = sql_manager.login(username, sql_manager.wrong_password_count(username))

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")

        elif command == 'send-reset-password':
            username = input("Enter your username: ")
            print(sql_manager.send_reset_password(username))

        elif command_array[0] == 'reset-password':
            print(sql_manager.reset_password(command_array[1]))

        elif command == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("exit - for closing program!")

        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:Dayana-Marinova,项目名称:HackBulgariaHomework,代码行数:52,代码来源:start.py


示例17: main_menu

def main_menu():
    print("Welcome to our bank service. You are not logged in.")
    print("Please register or login")

    while True:
        command = input("$$$>")

        if command == "register":
            username = input("Enter your username: ")
            password = getpass.getpass("Enter your password: ")
            email = input("Enter your email: ")

            sql_manager.register(username, password, email)

        elif command == "login":
            username = input("Enter your username: ")
            password = getpass.getpass("Enter your password: ")

            logged_user = sql_manager.login(username, password)

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")

        elif command == "send-reset-password":
            username = input("Enter your username: ")
            sql_manager.send_reset_pass_email(username)

        elif command == "reset-password":
            username = input("Enter your username: ")
            hash = input("Enter the hash code from your email: ")
            sql_manager.reset_password(username, hash)

        elif command == "help":
            print("login - for logging in!")
            print("register - for creating new account!")
            print("send-reset-password - to send a " "password reset code to your email!")
            print(
                "reset-password - to reset your password using a "
                "code from your email, to get it use the command above!"
            )
            print("exit - for closing the program!")

        elif command == "exit":
            break

        else:
            print("Not a valid command")
开发者ID:EmilianStankov,项目名称:Money-In-The-Bank,代码行数:49,代码来源:start.py


示例18: login

def login():
    username = input("Enter your username: ")
    password = getpass.getpass('Enter your password:')

    logged_user = sql_manager.login(username, password)

    if isinstance(logged_user, Client):
        user = LoggedUser(logged_user)
        user.user_menu()
    else:
        if logged_user['err_index'] == 0:
            sql_manager.change_last_log_try(username)
        else:
            pass
        print(logged_user['err_mess'])
开发者ID:ivannborisov,项目名称:Programming-101-v3,代码行数:15,代码来源:start.py


示例19: main_menu

def main_menu():
    print("Welcome to our bank service. You are not logged in. \nPlease register or login")

    while True:
        command = input("$$$>")

        if command == 'register':
            username = input("Enter your username: ")
            while True:
                password = getpass.getpass('Enter your password: ')
                if len(password) > 8 and not username in password and any(char.isdigit() for char in password) \
                    and any(x.isupper() for x in password) and any(x.islower() for x in password) \
                    and any(c in password for c in '*$&'):
                    break                                                                           #test
                else:
                    print("pass must\n-be more than 8 characters\n -must have capital letters and numbers and a special symbol\n -not containing the username")

            sql_manager.register(username, password)

            print("Registration Successfull")

        elif command == 'login':
            username = input("Enter your username: ")
            password = getpass.getpass('Enter your password: ')


            logged_user = sql_manager.login(username, password)

            if logged_user:
                logged_menu(logged_user)
            else:
                print("Login failed")
        elif "send-reset-password" in command:
            sql_manager.send_resetPass(command[20:])
        elif "Reset-password" in command:
            sql_manager.reset_pass(command[15:])
        elif command == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("send-reset-password <username>")
            print("Reset-password <username>")
            print("exit - for closing program!")

        elif command == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:golfdman,项目名称:HackBulgaria,代码行数:47,代码来源:start.py


示例20: 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: ")
            email = input("Enter your email: ")
            password = getpass.getpass(prompt='Password: ')

            sql_manager.register(username, password, email)

        elif command[0] == 'login':
            username = input("Enter your username: ")
            password = getpass.getpass(prompt='Password: ')

            if sql_manager.is_username_registered(username):
                logged_user = sql_manager.login(username, password)
                if logged_user:
                    logged_menu(logged_user)

                elif sql_manager.is_username_registered(username):
                    sql_manager.bruteforce_protect(username)
                    print("Incorrect username/password")

            else:
                print("Login failed")

        elif command[0] == 'send-reset-password':
            username = command[1]
            logged_user = sql_manager.reset_password(username)
            if logged_user:
                logged_menu(logged_user)
        elif command[0] == 'help':
            print("login - for logging in!")
            print("register - for creating new account!")
            print("send-reset-password [username] - for resetting password!")
            print("exit - for closing program!")

        elif command[0] == 'exit':
            break
        else:
            print("Not a valid command")
开发者ID:VasilVasilev93,项目名称:HackBulgaria,代码行数:44,代码来源:start.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sql_manager.register函数代码示例发布时间:2022-05-27
下一篇:
Python sql_manager.change_pass函数代码示例发布时间: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