2fa-0.7
This commit is contained in:
+5
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user