diff --git a/.app.py.swp b/.app.py.swp index af6b923..0985da4 100644 Binary files a/.app.py.swp and b/.app.py.swp differ diff --git a/.edit_email.tpl.swp b/.edit_email.tpl.swp index df42877..f23c332 100644 Binary files a/.edit_email.tpl.swp and b/.edit_email.tpl.swp differ diff --git a/.gitignore b/.gitignore index 155fc56..c1ad0d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /settings.ini /settings.ini.example.original /uwsgi.ini +/*.sw* session -libs/__pycache__ \ No newline at end of file +libs/__pycache__ diff --git a/.user.tpl.swp b/.user.tpl.swp index e819f0f..7b07e48 100644 Binary files a/.user.tpl.swp and b/.user.tpl.swp differ diff --git a/app.py b/app.py index b524e1d..736ba42 100644 --- a/app.py +++ b/app.py @@ -24,7 +24,7 @@ from bottle import SimpleTemplate from bottle.ext import beaker from configparser import ConfigParser from ldap3 import Server, Connection, ALL -from ldap3 import SIMPLE, SUBTREE, MODIFY_REPLACE, ALL_ATTRIBUTES +from ldap3 import SIMPLE, SUBTREE, MODIFY_REPLACE, MODIFY_ADD, ALL_ATTRIBUTES from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult, \ LDAPInvalidCredentialsResult, LDAPUserNameIsMandatoryError, \ LDAPSocketOpenError, LDAPExceptionError, LDAPAttributeOrValueExistsResult @@ -35,6 +35,7 @@ from libs.localization import * from libs.helper import * import random from user_agents import parse +from datetime import datetime BASE_DIR = path.dirname(__file__) LOG = logging.getLogger(__name__) @@ -397,9 +398,7 @@ def login_user_ldap(conf, username, password): # 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) + update_login_info(conf, user_dn) newSession().set(get_user_data(user_dn, c)) LOG.debug("%s logged in to %s" % (username, conf['base'])) @@ -515,9 +514,10 @@ def register(conf, username, firstname, surname, password, email, isFake, device uidNumber = find_uid_number(conf,c)+1 directory = 'home/user/'+to_ascii(username) OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] + t = datetime.now().strftime('%Y%m%d%H%M%S')+'Z' attributes = {'gidNumber': '501', 'uidNumber': uidNumber, 'homeDirectory': directory, 'givenName': firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake, - 'devices':device} + 'devices':device, 'ip':request.environ.get('HTTP_X_REAL_IP', request.remote_addr), 'lastLogin': t} 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 @@ -843,6 +843,18 @@ def get_dev(): user_agent = parse(ua_string) return str(user_agent) +def update_login_info(conf, user_dn): + superUser = SuperUsers(conf) + with connect_ldap(conf, user=superUser.admin_dn, password=superUser.admin_pwd) as c: + ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) + t = datetime.now().strftime('%Y%m%d%H%M%S')+'Z' + c.modify(user_dn, {'ip': [( MODIFY_REPLACE, str(ip) )], 'lastLogin': [( MODIFY_REPLACE, t )] }) + d = get_dev() + if not find_device(conf, c, d): + OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] + c.modify(user_dn, {'devices': [( MODIFY_ADD, d )] }) + c.unbind() + class Error(Exception): pass diff --git a/data/invite-codes.db b/data/invite-codes.db index fdfb63c..94d51b3 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 b39e905..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 97d4a2d..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 7afbe18..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 a9cacd8..a4cf099 100644 Binary files a/libs/__pycache__/slist.cpython-39.pyc and b/libs/__pycache__/slist.cpython-39.pyc differ diff --git a/user.tpl b/user.tpl index 944a4ea..f9d2a0e 100644 --- a/user.tpl +++ b/user.tpl @@ -51,6 +51,17 @@ {{ str['edit'] }} +
+
+
Erregistroak
+
+
+ +
+ ikusi +
+ +