Sản phẩm đăng nhập và đăng xuất khi đăng ký sản phẩm
sUsser = []
dsPass = []
dsCharNum = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
dsCharSpecial = ['!', '@', '#', '$', '%', '^', '&', '*']
def checkPassword(password):
bUpper = False
bNum = False
bSpecial = False
for x in password:
if x.isupper():
bUpper = True
if x in dsCharNum:
bNum = True
if x in dsCharSpecial:
bSpecial = True
if bUpper and bNum and bSpecial:
return 1
else:
return 0
def createAccount():
tendangnhap = ''
while (tendangnhap == '' or tendangnhap in dsUsser):
tendangnhap = str(input('Xin mời nhập tên đăng nhập:')).strip()
passdangnhap = ''
bCheck = False
while not bCheck:
passdangnhap = input('Xin mời nhập mật khẩu:')
if len(passdangnhap) < 8:
print('Mật khẩu phải có độ dài lớn hơn 8 ký tự')
passdangnhap = input('Xin mời nhập lại mật khẩu:')
elif checkPassword(passdangnhap) == 0:
print('Mật khẩu phải chứa kí tự viết hoa, số và ký tự đặc biệt')
passdangnhap = input('Xin mời nhập lại mật khẩu:')
else:
bCheck = True
dsUsser.append(tendangnhap.lower())
dsPass.append(passdangnhap)
print('Bạn đã tạo tài khoản thành công')
def changePassword(tendangnhap):
passdangnhap = ''
bCheck = False
while not bCheck:
passdangnhap = input('Xin mời nhập mới mật khẩu:')
if len(passdangnhap) < 8:
print('Mật khẩu phải có độ dài lớn hơn 8 ký tự')
elif checkPassword(passdangnhap) == 0:
print('Mật khẩu phải chứa kí tự viết hoa, số và ký tự đặc biệt')
else:
bCheck = True
dsPass[dsUsser.index(tendangnhap)] = passdangnhap
print('Bạn đã đổi mật khẩu thành công')
def login():
tendangnhap = str(input('Xin mời nhập tên đăng nhập:')).strip().lower()
passdangnhap = input('Xin mời nhập mật khẩu:')
if tendangnhap in dsUsser and dsPass[dsUsser.index(tendangnhap)] == passdangnhap:
print('Bạn đã đăng nhập tài khoản thành công')
a = int(input('Bấm số 1 để dổi mất khẩu, số 0 để bỏ qua: '))
if a == 1:
changePassword(tendangnhap)
else:
print('Bạn nhập sai tài khoản hoặc mật khẩu của bạn')
def start():
dichvu = int(input('Xin mời chọn dịch vụ bấm số 1 để đăng kí số 2 để đăng nhập: '))
print('************************************')
if dichvu == 1:
createAccount()
if dichvu == 2:
login()
bContinue = 1
print('Chào mừng đến với trang web của Vũ Nam Phong')
while bContinue == 1:
start()
bContinue = int(input('Bạn nhấn 1 để tiếp tục, nhấn 0 để kết thúc: '))
print('Cảm ơn quý khách và hẹn gặp lại!')
Spt
Đăng nhập để tham gia bình luận
hay
Đăng nhập để tham gia bình luận
.
Đăng nhập để tham gia bình luận
.
Đăng nhập để tham gia bình luận
.
Đăng nhập để tham gia bình luận
Đăng nhập để tham gia bình luận