本文整理汇总了Python中sql_manager.change_pass函数的典型用法代码示例。如果您正苦于以下问题:Python change_pass函数的具体用法?Python change_pass怎么用?Python change_pass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了change_pass函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
示例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')
示例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")
示例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")
示例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")
示例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")
示例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")
示例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"))
示例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])
示例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")
示例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")
示例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
示例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")
示例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")
示例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)