This commit is contained in:
2023-11-18 20:44:06 +01:00
parent fc224038a3
commit 4d2cf64f19
5 changed files with 86 additions and 32 deletions
+5 -2
View File
@@ -4,6 +4,7 @@ import sqlite3
import re
from onetimepass import valid_totp
from secrets import choice
import segno
class Tools():
@@ -44,12 +45,14 @@ class Tools():
def pwd_validation(self, e):
regex = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{8,18}$'
return(bool(re.fullmatch(regex, e)))
# 2FA
def generate_secret(self): # Function to return a random string with length 16.
secret = ''
while len(secret) < 16:
secret += choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567')
qrcode = segno.make(secret, micro=False)
qrcode.save('static/tmp/'+secret+'.png', scale=10)
return secret
tools = Tools()