diff --git a/.app.py.swo b/.app.py.swo new file mode 100644 index 0000000..97a4be9 Binary files /dev/null and b/.app.py.swo differ diff --git a/.app.py.swp b/.app.py.swp new file mode 100644 index 0000000..af6b923 Binary files /dev/null and b/.app.py.swp differ diff --git a/.edit_email.tpl.swp b/.edit_email.tpl.swp new file mode 100644 index 0000000..df42877 Binary files /dev/null and b/.edit_email.tpl.swp differ diff --git a/.index.tpl.swp b/.index.tpl.swp new file mode 100644 index 0000000..ed3553c Binary files /dev/null and b/.index.tpl.swp differ diff --git a/.user.tpl.swp b/.user.tpl.swp new file mode 100644 index 0000000..e819f0f Binary files /dev/null and b/.user.tpl.swp differ diff --git a/app.py b/app.py index 23055ae..b524e1d 100644 --- a/app.py +++ b/app.py @@ -390,10 +390,16 @@ def login_user_ldap(conf, username, password): #with connect_ldap(conf) as c: with connect_ldap(conf, user=superUser.readonly_dn, password=superUser.readonly_pwd) as c: user_dn = find_user_dn(conf, c, username) - + cur_dev = get_dev() + known_device = find_device(conf, c, cur_dev) + print('KNOWN DEVICE:',known_device) + print(request.environ.get('HTTP_X_REAL_IP', request.remote_addr)) # Note: raises LDAPUserNameIsMandatoryError when user_dn is None. with connect_ldap(conf, authentication=SIMPLE, user=user_dn, password=password) as c: c.bind() + #IP helbidea sartu db-an + ip = {'ip':request.environ.get('HTTP_X_REAL_IP', request.remote_addr)} + c.add(attributes=ip) newSession().set(get_user_data(user_dn, c)) LOG.debug("%s logged in to %s" % (username, conf['base'])) @@ -510,7 +516,8 @@ def register(conf, username, firstname, surname, password, email, isFake, device 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, 'device':device} + firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake, + 'devices':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 @@ -760,6 +767,17 @@ def find_email(conf, conn, email): return False +#find devices +def find_device(conf, conn, device): + search_filter = '(uid=*)' + if conn.search(conf['base'], search_filter, attributes=['devices']): + for i in conn.response: + for j in i['attributes']['devices']: + if(j == device): + return True + + return False + #find highest uidNumber def find_uid_number(conf, conn): search_filter = '(uid=*)' @@ -786,7 +804,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','device']) + conn.search(user_dn, search_filter, attributes=['active','fakeCn','givenName','sn','uid','mail','devices']) data = [] data.append(conn.entries[0].active.values[0]) data.append(conn.entries[0].fakeCn.values[0]) @@ -794,7 +812,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) + data.append(conn.entries[0].devices.values) return(data) def read_config(): @@ -825,7 +843,6 @@ def get_dev(): user_agent = parse(ua_string) return str(user_agent) - class Error(Exception): pass @@ -863,7 +880,7 @@ def newSession(): self.surname = data[3] self.username = data[4] self.mail = data[5] - self.device = data[6] + self.devices = data[6] self.data['active'] = self.active self.data['fakeCn'] = self.fakeCn @@ -871,7 +888,7 @@ def newSession(): self.data['surname'] = self.surname self.data['username'] = self.username self.data['mail'] = self.mail - self.data['device'] = self.device + self.data['devices'] = self.devices def close(self): self.data.pop('username') diff --git a/data/invite-codes.db b/data/invite-codes.db index eec80d4..fdfb63c 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 0ea818d..b39e905 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 7f6d266..97d4a2d 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 3ac33b3..7afbe18 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 a4cf099..a9cacd8 100644 Binary files a/libs/__pycache__/slist.cpython-39.pyc and b/libs/__pycache__/slist.cpython-39.pyc differ