find_device
This commit is contained in:
+29
-29
@@ -5,42 +5,42 @@ import re
|
||||
|
||||
class Tools():
|
||||
|
||||
def __init__(self):
|
||||
self.username = ''
|
||||
def __init__(self):
|
||||
self.username = ''
|
||||
|
||||
#check code
|
||||
def code_is_valid(self, code, db):
|
||||
con = sqlite3.connect(db)
|
||||
cur = con.cursor()
|
||||
#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))
|
||||
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()
|
||||
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()
|
||||
cur.execute('''UPDATE codes SET valid=? WHERE code==?''',(0, code))
|
||||
con.commit()
|
||||
|
||||
#form validation
|
||||
#form validation
|
||||
|
||||
def input_validation(self, e, ws=None):
|
||||
if ws:
|
||||
#accepts whitespaces
|
||||
regex = r'^\w+( \w+)*$'
|
||||
else:
|
||||
regex = r'^\w+$'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
def input_validation(self, e, ws=None):
|
||||
if ws:
|
||||
#accepts whitespaces
|
||||
regex = r'^\w+( \w+)*$'
|
||||
else:
|
||||
regex = r'^\w+$'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
|
||||
def email_validation(self, e):
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
def email_validation(self, e):
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
|
||||
def pwd_validation(self, e):
|
||||
regex = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{8,18}$'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
def pwd_validation(self, e):
|
||||
regex = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{8,18}$'
|
||||
return(bool(re.fullmatch(regex, e)))
|
||||
|
||||
tools = Tools()
|
||||
|
||||
Reference in New Issue
Block a user