diff --git a/_2fa.tpl b/_2fa.tpl
new file mode 100644
index 0000000..d90e171
--- /dev/null
+++ b/_2fa.tpl
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+ {{ str['welcome'] }}
+
+
+
+
+
+
+ 2FA
+
+
+
+ %for type, text, animation in get('alerts', []):
+
+ %end
+
+
+
+
+
diff --git a/app.py b/app.py
index f59aac3..9dbb58d 100644
--- a/app.py
+++ b/app.py
@@ -100,7 +100,6 @@ def get_index():
except Exception as e:
return index_tpl(str=i18n.str)
-
@get('/logout')
def get_index():
@@ -117,6 +116,13 @@ def get_index():
return index_tpl(alerts=[('success', i18n.msg[0], 'fadeOut')], str=i18n.str)
+@get('/_2fa')
+def get_index():
+ try:
+ return _2fa_tpl(data=newSession().get(), str=i18n.str)
+ except Exception as e:
+ return index_tpl(str=i18n.str)
+
@post('/user')
def post_user():
form = request.forms.getunicode
@@ -138,7 +144,10 @@ def post_user():
LOG.warning("Unsuccessful attempt to login %s: %s" % (form('username'), e))
return error(str(e))
+ #if 2fa not chekced || (2fa checked & success)
return user_tpl(alerts=[('success', '%s %s' % (i18n.msg[1], form('username').capitalize()), 'fadeOut' )], data=newSession().get(), str=i18n.str)
+ #elif 2fa checked
+ #return _2fa_tpl(alerts=[('success', '%s %s' % (i18n.msg[1], form('username').capitalize()), 'fadeOut' )], data=newSession().get(), str=i18n.str)
@post('/signup')
def post_signup():
@@ -347,6 +356,9 @@ def delete_tpl(**kwargs):
def logs_tpl(**kwargs):
return template('logs', **kwargs)
+def _2fa_tpl(**kwargs):
+ return template('_2fa', **kwargs)
+
def connect_ldap(conf, **kwargs):
server = Server(host=conf['host'],
port=conf.getint('port', None),
@@ -520,7 +532,8 @@ def register(conf, username, firstname, surname, password, email, isFake, device
ts = 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, 'ip':request.environ.get('HTTP_X_REAL_IP', request.remote_addr), 'lastLogin': ts}
+ 'devices':device, 'ip':request.environ.get('HTTP_X_REAL_IP', request.remote_addr), 'lastLogin': ts,
+ 'secureAuth': False}
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
@@ -807,7 +820,8 @@ 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','devices','ip','lastLogin'])
+ conn.search(user_dn, search_filter,
+ attributes=['active','fakeCn','givenName','sn','uid','mail','devices','ip','lastLogin','secureAuth'])
data = []
data.append(conn.entries[0].active.values[0])
data.append(conn.entries[0].fakeCn.values[0])
@@ -821,6 +835,7 @@ def get_user_data(user_dn, conn):
#ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S%z')
#ts = datetime.strftime(t, '%Y-%m-%d %H:%M:%S')
data.append(str(conn.entries[0].lastLogin.values[0])[:-6])
+ data.append(conn.entries[0].secureAuth.values[0])
return(data)
@@ -922,6 +937,7 @@ def newSession():
self.devices = data[6]
self.ip = data[7]
self.lastLogin = data[8]
+ self.secureAuth = data[9]
self.data['active'] = self.active
self.data['fakeCn'] = self.fakeCn
@@ -932,6 +948,7 @@ def newSession():
self.data['devices'] = self.devices
self.data['ip'] = self.ip
self.data['lastLogin'] = self.lastLogin
+ self.data['secureAuth'] = self.secureAuth
def close(self):
self.data.pop('username')
diff --git a/static/style.css b/static/style.css
index c5078db..3607561 100644
--- a/static/style.css
+++ b/static/style.css
@@ -197,7 +197,9 @@ button.red:hover{
/**/
.grid-container {
display: grid;
- grid-template-columns: auto max-content;
+ /*grid-template-columns: auto max-content;*/
+ grid-template-areas: 'bat bi'
+ 'hiru hiru';
margin: 0 auto;
max-width: 16rem;
padding: 0 2.5rem 0 2.5rem;
@@ -220,6 +222,17 @@ button.red:hover{
display: unset;
max-width: max-content;
}
+
+.item1 {
+ grid-area: bat;
+}
+.item2 {
+ grid-area: bi;
+ text-align: right;
+}
+.item3{
+ grid-area: hiru;
+}
/**/
@media only screen and (max-width: 480px) {
diff --git a/user.tpl b/user.tpl
index 1aaf444..8ddb468 100644
--- a/user.tpl
+++ b/user.tpl
@@ -16,71 +16,82 @@
{{ str['welcome'] }} {{ data['username'] }}
-
+
{{ str['usr'] }}
{{ data['firstname'] }} {{ data['surname'] }}
-
+
-
+
-
-
+
+
+
+
{{ str['email'] }}
{{ data['mail'] }}
-
+
-
-
+
+
+
+
{{ str['pwd'] }}
********
-
-
+
+
-
+
+
+
-
-
+
-
%for type, text, animation in get('alerts', []):