Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Refactoring of the TOTP offset message
· 52266ea5
Marco De Donno
authored
Sep 11, 2019
52266ea5
Load the ProxyFix module
· f4c5b301
Marco De Donno
authored
Sep 12, 2019
f4c5b301
Show whitespace changes
Inline
Side-by-side
config.py
View file @
f4c5b301
...
@@ -27,6 +27,8 @@ session_timeout = int( os.environ.get( "SESSION_TIMEOUT", 15 * 60 ) )
...
@@ -27,6 +27,8 @@ session_timeout = int( os.environ.get( "SESSION_TIMEOUT", 15 * 60 ) )
TOTP_VALIDWINDOW
=
5
TOTP_VALIDWINDOW
=
5
PROXY
=
os
.
environ
.
get
(
"
BEHIND_PROXY
"
,
True
)
pianosurl
=
os
.
environ
.
get
(
"
DB_PIANOS_URL
"
,
"
pgsql://pianos:pianos@pianos/pianos
"
)
pianosurl
=
os
.
environ
.
get
(
"
DB_PIANOS_URL
"
,
"
pgsql://pianos:pianos@pianos/pianos
"
)
pianosdb
=
DatabasePiAnoS
(
pianosurl
)
pianosdb
=
DatabasePiAnoS
(
pianosurl
)
pianosendpoint
=
os
.
environ
.
get
(
"
PIANOS_ENDPOINT
"
,
"
/pianos
"
)
pianosendpoint
=
os
.
environ
.
get
(
"
PIANOS_ENDPOINT
"
,
"
/pianos
"
)
...
...
module.py
View file @
f4c5b301
...
@@ -26,6 +26,7 @@ from flask import url_for
...
@@ -26,6 +26,7 @@ from flask import url_for
from
flask_compress
import
Compress
from
flask_compress
import
Compress
from
flask_session
import
Session
from
flask_session
import
Session
from
werkzeug
import
abort
,
redirect
from
werkzeug
import
abort
,
redirect
from
werkzeug.middleware.proxy_fix
import
ProxyFix
import
gnupg
import
gnupg
import
pyotp
import
pyotp
import
pytz
import
pytz
...
@@ -61,6 +62,9 @@ app.config.from_pyfile( "config.py" )
...
@@ -61,6 +62,9 @@ app.config.from_pyfile( "config.py" )
Compress
(
app
)
Compress
(
app
)
Session
(
app
)
Session
(
app
)
if
config
.
PROXY
:
app
.
wsgi_app
=
ProxyFix
(
app
.
wsgi_app
)
baseurl
=
os
.
environ
.
get
(
"
BASEURL
"
,
""
)
baseurl
=
os
.
environ
.
get
(
"
BASEURL
"
,
""
)
envtype
=
os
.
environ
.
get
(
"
ENVTYPE
"
,
""
)
envtype
=
os
.
environ
.
get
(
"
ENVTYPE
"
,
""
)
...
...
templates/login.html
View file @
f4c5b301
...
@@ -183,14 +183,19 @@
...
@@ -183,14 +183,19 @@
var
time_diff
=
data
.
time_diff
;
var
time_diff
=
data
.
time_diff
;
time_diff
=
Math
.
abs
(
time_diff
);
time_diff
=
Math
.
abs
(
time_diff
);
time_diff
=
moment
.
duration
(
time_diff
,
"
seconds
"
)
time_diff_h
=
Math
.
floor
(
time_diff
/
3600
);
time_diff
=
moment
.
utc
(
time_diff
.
asMilliseconds
()
).
format
(
"
mm
"
);
time_diff_m
=
Math
.
floor
(
(
time_diff
-
time_diff_h
*
3600
)
/
60
);
var
time_diff_msg
=
"
Your phone time is probably off by
"
if
(
time_diff_h
>
0
)
time_diff_msg
+=
time_diff_h
+
"
hour(s) and
"
time_diff_msg
+=
time_diff_m
+
"
minute(s).
"
;
$
(
"
#icnml_login_warning
"
)
$
(
"
#icnml_login_warning
"
)
.
css
(
"
margin-bottom
"
,
"
0px
"
);
.
css
(
"
margin-bottom
"
,
"
0px
"
);
$
(
"
#icnml_login_warning2
"
)
$
(
"
#icnml_login_warning2
"
)
.
text
(
"
Your phone time is probably off by
"
+
time_diff
+
"
minutes
"
);
.
text
(
time_diff_msg
);
}
}
}
}
}
}
...
...