Add registration code

This commit is contained in:
Anthony Wang 2021-11-23 15:58:25 -06:00
parent 9df4ff1af6
commit a4820fae58
Signed by: a
GPG key ID: BC96B00AEC5F2D76
2 changed files with 7 additions and 3 deletions

View file

@ -33,9 +33,9 @@ else:
if interactive:
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()[:-1]
print('Password:', password)
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
else:
password = sys.argv[5]
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
hashedpassword = sys.argv[5]
# Construct LDIF

View file

@ -9,7 +9,10 @@ class S(BaseHTTPRequestHandler):
content_length = int(self.headers['Content-Length'])
data = loads(self.rfile.read(content_length).decode('utf-8'))
print(data)
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + data['password'] + ' "' + ldap_pass + '"')
if data['code'] != code:
return
hashedpassword = os.popen('slappasswd -s ' + data['password']).read()[:-1]
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + hashedpassword + ' "' + ldap_pass + '"')
self.send_response(200)
self.send_header('Content-type', 'text/html')
@ -21,4 +24,5 @@ def run(server_class=HTTPServer, handler_class=S):
httpd.serve_forever()
ldap_pass = input('LDAP password: ')
code = input('Registration code: ')
run()