Add 2FA support
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user