Skip to content

Instantly share code, notes, and snippets.

@EricsonWillians
Created October 21, 2015 00:37
Show Gist options
  • Save EricsonWillians/8d1c6f551c1360d42b2f to your computer and use it in GitHub Desktop.
Save EricsonWillians/8d1c6f551c1360d42b2f to your computer and use it in GitHub Desktop.
An example for someone in a facebook group.
# Super PyLogin 3000
import sys
USERS = {}
def create_account(username, password):
if not username in USERS:
USERS[username] = password
print("Account created")
else:
print("Username already taken.")
def authenticate_user(username, password):
if USERS:
if username in USERS:
if USERS[username] == password:
print("Access granted.\nWelcome, {user}!".format(user = username))
# Do stuff once having access...
sys.exit()
else:
print("Access denied.")
def main():
print("Super PyLogin 3000,\nBy Ericson Willians.")
while 1:
if not USERS:
print("The system has no accounts, please create one.")
create_account(input("Username: "), input("Password: "))
else:
if int(input("What do you want to do? Create a new account (0) or login with an existing one? (1), just type the number: ")):
authenticate_user(input("Username: "), input("Password: "))
else:
create_account(input("Username: "), input("Password: "))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment