Sign up to the awesomeness of this cool project and get yourself started!
Let's begin!
The script is for developing a program through which we can get user register. We can also create any user admin with a hidden command or "cheat code".
As usual a regular user can see it's own information while an admin can see every on of them!
It's basic and many other cool stuffs can be added in it!
So, sit back and relax and let your creativity take over and create something amazing!
Happy Programming!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def password_check(a, u): # function to check password guidelines | |
if len(a) < 7: | |
print("Password should be more than 8 digits") | |
elif u in a: | |
print("password should not contain username") | |
else: | |
print("Strong Password") | |
def user_access(a, x, y): # function for user options | |
a = a.lower() | |
if a == "yes": | |
print("Your Data") | |
print(x) | |
print(y) | |
def admin(a, detail): # function for admin access | |
a = a.lower() | |
if a == "admin": # to access this function more like a cheat code | |
print("You have admin access ") | |
for i in detail: | |
i = i.split("_") | |
# Before '_' will be username | |
print("Username: " + i[0]) | |
# After '_' will be password | |
print("Password: " + i[1]) | |
register = [] # List to save username and function | |
operation = 3 # Initialise the loop | |
while operation != "0": # Termination condition i.e. 0 in our case | |
operation = input("To login enter 1\nTo register enter 2\nEnter 0 to Exit\n") | |
if operation == '1': # For Login | |
username = input("Enter username: ") | |
password = input("Enter password: ") | |
userid = username + '_' + password | |
if userid in register: | |
print("Welcome "+username.upper()+" !") # Salutation | |
operation = input("Would you like to view data: ") | |
admin(operation, register) # To activate function with the following parameters | |
user_access(operation, username, password) # To activate function with the following parameters | |
operation = input("Enter 1 to Log Out\n") # To exit the condition | |
else: | |
print("Wrong Username or Password") | |
elif operation == '2': # For registration | |
username = input("Enter username: ") | |
password = input("Enter password: ") | |
password_check(password, username) # To activate function with the following parameters | |
while len(password) < 7 or username in password: # Retake the value if the following problem occurs | |
password = input("Enter password: ") | |
password_check(password, username) | |
userid = username + '_' + password # To save the username and password in a single string | |
# Single string will be used to check whether the username and password same for each other | |
if userid in register: # if already registered | |
print("Already registered!") | |
else: | |
register.append(userid) # Save userid in our list | |
print("You've been successfully registered!") | |
else: # for any other input | |
print("Wrong Input") |
Comments
Post a Comment