diff --git a/static/pywallter.css b/static/pywallter.css
index 3471d64..b4c93f7 100644
--- a/static/pywallter.css
+++ b/static/pywallter.css
@@ -16,6 +16,10 @@ body
visibility: hidden;
}
+.hidden{
+ visibility: hidden;
+}
+
header {
grid-area: header;
}
@@ -38,7 +42,15 @@ main > nav
margin-bottom: 4vw;
}
+/*Color text */
+.alert {
+ color: var(--pico-color-red-500);
+}
+
+.success {
+ color: var(--pico-color-green-500);
+}
@media only screen and (max-width: 600px)
{
@@ -167,6 +179,12 @@ footer
color: var(--pico-color-red-50);
}
+.btn-alert {
+ background-color: var(--pico-color-red-550);
+ color: var(--pico-color-red-50);
+}
+
+
article {
text-align: center;
}
diff --git a/templates/_js-core.html b/templates/_js-core.html
index c8579a8..0ac52b2 100644
--- a/templates/_js-core.html
+++ b/templates/_js-core.html
@@ -1,3 +1,4 @@
+
diff --git a/tools/databaseinit.py b/tools/databaseinit.py
index f622bba..9a61c02 100755
--- a/tools/databaseinit.py
+++ b/tools/databaseinit.py
@@ -30,6 +30,7 @@ def init_db():
age TEXT,
website TEXT,
blog_theme TEXT,
+ totp CHAR(40),
Token CHAR(64),
Lost_password_token CHAR(128),
invitations INTEGER DEFAULT (20),
@@ -96,14 +97,16 @@ def db_migrate():
blog_theme_col = False
updated_col = False
lost_password_token_col = False
-
+ totp_col = False
+
for col in db_columns:
if "invitations" == col[0]:
invitations_col = True
if "Lost_password_token" == col[0]:
lost_password_token_col = True
-
-
+ if "totp" == col[0]:
+ totp_col = True
+
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('Blog_posts');""")
db_columns = cursor.fetchall()
for col in db_columns:
@@ -125,6 +128,12 @@ def db_migrate():
conn.commit()
print ("Ajout du champ Lost_password_token dans la table Users")
+ if not(totp_col):
+ cursor.execute("""ALTER TABLE Users ADD COLUMN totp CHAR(40);""")
+ conn.commit()
+ print ("Ajout du champ totp dans la table Users")
+
+
if not(blog_theme_col):
cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN blog_theme TEXT;""")
@@ -136,6 +145,6 @@ def db_migrate():
conn.commit()
print ("Ajout du champ updated dans la table BLog")
-
+
conn.close()
diff --git a/tools/utils.py b/tools/utils.py
index 50ed7e5..8233cf3 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -3,6 +3,8 @@ import sqlite3
import os
import string
import random
+import time
+import pyotp
app = Flask( 'pywallter' )
app.config.from_pyfile('config.py')
@@ -129,3 +131,13 @@ def gen_token(token_type):
case "Lost password":
sample = ''.join(random.sample(digits + letters, 64))
return sample
+
+def totp_is_valid(code_key, code):
+ res = True
+
+ if code_key:
+ mytotp = pyotp.TOTP(code_key)
+ if not(code == mytotp.now() and res):
+ res = False
+
+ return res