diff --git a/app.py b/app.py index e1e4e46..23055ae 100644 --- a/app.py +++ b/app.py @@ -186,8 +186,8 @@ def post_signup(): elif form('password') != form('confirm-password'): return error(i18n.msg[7]) - try: - account_request(username, firstname, surname, form('password'), email, isFake) + try: + account_request(username, firstname, surname, form('password'), email, isFake, get_dev()) except Error as e: LOG.warning("Unsuccessful attempt to create an account for %s: %s" % (form('username'), e)) return error(str(e)) @@ -444,14 +444,14 @@ def logout_user_ldap(conf, username): LOG.info("%s LOGED OUT" % (username)) #SIGN UP -def account_request(username, firstname, surname, password, email, isFake): +def account_request(username, firstname, surname, password, email, isFake, device): created = [] for key in (key for key in CONF.sections() if key == 'ldap' or key.startswith('ldap:')): LOG.debug("Creating account for %s on %s server" % (username, key)) try: - new_user_account(CONF[key], username, firstname, surname, password, email, isFake) + new_user_account(CONF[key], username, firstname, surname, password, email, isFake, device) created.append(key) except Error as e: for key in reversed(created): @@ -478,7 +478,7 @@ def new_user_account(conf, *args): LOG.error('{}: {!s}'.format(e.__class__.__name__, e)) raise Error(i18n.msg[23]) -def register(conf, username, firstname, surname, password, email, isFake): +def register(conf, username, firstname, surname, password, email, isFake, device): def to_ascii(str): ascii_str="" @@ -509,7 +509,8 @@ def register(conf, username, firstname, surname, password, email, isFake): uidNumber = find_uid_number(conf,c)+1 directory = 'home/user/'+to_ascii(username) OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] - attributes = {'gidNumber': '501', 'uidNumber': uidNumber, 'homeDirectory': directory, 'givenName': firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake} + attributes = {'gidNumber': '501', 'uidNumber': uidNumber, 'homeDirectory': directory, 'givenName': + firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake, 'device':device} new_user_dn = "cn="+firstname+" "+surname+" - "+username+",cn=users,"+conf['base'] c.add(dn=new_user_dn,object_class=OBJECT_CLASS, attributes=attributes) #create/change user password @@ -785,7 +786,7 @@ def get_user_email_array(user_dn, conn, old_email, new_email): def get_user_data(user_dn, conn): search_filter = '(objectClass=*)' - conn.search(user_dn, search_filter, attributes=['active','fakeCn','givenName','sn','uid','mail']) + conn.search(user_dn, search_filter, attributes=['active','fakeCn','givenName','sn','uid','mail','device']) data = [] data.append(conn.entries[0].active.values[0]) data.append(conn.entries[0].fakeCn.values[0]) @@ -793,6 +794,7 @@ def get_user_data(user_dn, conn): data.append(conn.entries[0].sn.values[0]) data.append(conn.entries[0].uid.values[0]) data.append(conn.entries[0].mail.values[0]) + data.append(conn.entries[0].device.values) return(data) def read_config(): @@ -818,6 +820,12 @@ def reg(): allowed = reg() +def get_dev(): + ua_string = bottle.request.environ.get('HTTP_USER_AGENT') + user_agent = parse(ua_string) + return str(user_agent) + + class Error(Exception): pass @@ -835,14 +843,6 @@ def newSession(): global i18n i18n = LocalizeTo(self.lang, CONF) - self.device = self.get_dev() - - def get_dev(self): - ua_string = bottle.request.environ.get('HTTP_USER_AGENT') - user_agent = parse(ua_string) - - return str(user_agent) - def get_lang(self): if 'HTTP_ACCEPT_LANGUAGE' in bottle.request.environ: lang = bottle.request.get('HTTP_ACCEPT_LANGUAGE') @@ -863,6 +863,7 @@ def newSession(): self.surname = data[3] self.username = data[4] self.mail = data[5] + self.device = data[6] self.data['active'] = self.active self.data['fakeCn'] = self.fakeCn diff --git a/data/invite-codes.db b/data/invite-codes.db index b718294..eec80d4 100644 Binary files a/data/invite-codes.db and b/data/invite-codes.db differ diff --git a/libs/__pycache__/flist.cpython-39.pyc b/libs/__pycache__/flist.cpython-39.pyc index a49c14a..0ea818d 100644 Binary files a/libs/__pycache__/flist.cpython-39.pyc and b/libs/__pycache__/flist.cpython-39.pyc differ diff --git a/libs/__pycache__/helper.cpython-39.pyc b/libs/__pycache__/helper.cpython-39.pyc index b7a2554..7f6d266 100644 Binary files a/libs/__pycache__/helper.cpython-39.pyc and b/libs/__pycache__/helper.cpython-39.pyc differ diff --git a/libs/__pycache__/localization.cpython-39.pyc b/libs/__pycache__/localization.cpython-39.pyc index 6d886df..3ac33b3 100644 Binary files a/libs/__pycache__/localization.cpython-39.pyc and b/libs/__pycache__/localization.cpython-39.pyc differ diff --git a/libs/__pycache__/slist.cpython-39.pyc b/libs/__pycache__/slist.cpython-39.pyc index f9e30c6..a4cf099 100644 Binary files a/libs/__pycache__/slist.cpython-39.pyc and b/libs/__pycache__/slist.cpython-39.pyc differ