Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Register():
- print('Register your login: ', end='')
- login = input()
- print('Register your password ', end='')
- password = input()
- checkPassword(password)
- Rights()
- fileNames = open('usernames.txt', 'a')
- fileNames.write('\n' + login)
- filePasswords = open('passwords.txt', 'a')
- filePasswords.write('\n' + password)
- fileRights = open('privileges.txt', 'a')
- fileRights.write('\n' + Rights())
- def checkPassword(password):
- if len(password) == 4:
- return True
- else:
- print('Password length must be 4 symbols!')
- newPassword = input()
- checkPassword(newPassword)
- def Rights():
- print('Choose your rights: D or/and C ', end='')
- rights = input().strip()
- if rights == 'C':
- return 'C'
- elif rights == 'D':
- return 'D'
- elif rights == 'C and D' or 'D and C' or 'C, D' or 'D, C':
- return 'C D'
- else:
- print('You are trying to put wrong rights')
- Rights()
- import getpass
- import numpy as np
- import registration
- class User:
- def __init__(self, name, password, privilege):
- self.name = name
- self.password = password
- self.privilege = privilege
- def Authentificate():
- while True:
- print('Login: ', end='')
- name = input()
- password = getpass.getpass('Enter password:')
- usernames = open('usernames.txt', 'r')
- passwords = open('passwords.txt', 'r')
- privileges = open('privileges.txt', 'r')
- dataname = np.array(usernames.read().split('\n'))
- datapass = np.array(passwords.read().split('\n'))
- dataprivilege = np.array(privileges.read().split('\n'))
- numbUsers = int(dataname.size)
- loginCheck = False
- for i in range(numbUsers):
- if dataname[i] == name:
- loginCheck = True
- if datapass[i] == password:
- print('You have rights of category: ', dataprivilege[i])
- return User(name, password, dataprivilege[i])
- break
- else:
- print('Wrong password')
- if loginCheck == False:
- print('Wrong login')
- def Reg():
- answer = input()
- if answer == 'y':
- registration.Register()
- elif answer == 'n':
- Authentificate()
- else:
- print('Enter y or n')
- Reg()
- print('Do you want to register new user? y/n ', end='')
- Reg()
- Authentificate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement