Add 2FA support

This commit is contained in:
2025-11-05 20:36:46 +01:00
parent b19393562c
commit 42c610f37f
4 changed files with 44 additions and 4 deletions

View File

@@ -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