#!/usr/bin/env python # -*- coding: utf-8 -*-
user_allow = []
user_deny = []
while True:
banner = "Welcome"
print(banner.center(20,"="))
if user_allow:
for i in range(3):
banner_login = "Please enter your name and password to login!"
print(banner_login)
lname = input("Login Name:")
lpwd = input("Login Password:")
if user_deny:
for m in range(len(user_deny)):
if lname == user_deny[m][0]:
print("It is locked. Please contract your administrator !")
else:
pass
for n in range(len(user_allow)):
if lname == user_allow[n][0] and lpwd == user_allow[n][1]:
print("Welcome %s to login !" % lname)
select = input("List[l]| Reset password [c]| Users[a]| Logout[x]:")
if select == "l":
for luser in range(len(user_allow)):
print(user_allow[luser][0])
break
elif select == "x":
print("Logout! Bye bye !")
break
elif select == "c":
print("Now reseting the password...")
opwd = input("Your old password:")
npwd = input("Your new password:")
npwd2 = input("Confirm:")
if npwd == npwd2:
if opwd == user_allow[n][1]:
user_allow[n][1] = npwd2
print("The password is updated!")
else:
print("It is not match !")
continue
elif select == "a":
print("==Add new user info==")
add_user = input("The new account:")
add_pwd1 = input("The password:")
add_pwd2 = input("Confirm:")
if add_user not in user_allow and add_pwd1 == add_pwd2:
user_allow.append([add_user,add_pwd2])
print("The user is added.")
continue
else:
print("It is not match!")
continue
else:
i = 2 - i
if i > 0 and i <=2 :
print("Sorry,you have %s times" % i)
elif i == 0:
print("Sorry,your account is locked!")
user_deny.append([lname,lpwd])
exit()
else:
print("Please register first!")
uname = input("New Name:")
upwd = input("New Password:")
user_allow.append([uname,upwd])
print("The register is successful !")