ldap-python-webui/libs/helper.py

25 lines
565 B
Python
Raw Normal View History

2022-04-16 23:13:00 +02:00
#!/usr/bin/python3
import sqlite3
class Tools():
def __init__(self):
self.username = ''
#check code
def code_is_valid(self, code, db):
con = sqlite3.connect(db)
cur = con.cursor()
codes=[]
for row in cur.execute('SELECT * FROM codes WHERE valid = 1'):
codes.append(row[0])
return(bool(code in codes))
def mark_code_as_used(self, code, db):
con = sqlite3.connect(db)
cur = con.cursor()
cur.execute('''UPDATE codes SET valid=? WHERE code==?''',(0, code))
con.commit()