-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.py
32 lines (28 loc) · 892 Bytes
/
User.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flask.ext.login import LoginManager, UserMixin, login_required
import sqlite3 as lite
database = 'reviews.sqlite'
class User(UserMixin):
def __init__(self, username):
self.id = username
self.authenticated = True
self.active = True
@classmethod
def get(cls, id, is_email):
if Check_For_ID(id, is_email):
return User(id)
else:
return None
def Check_For_ID(id, is_email):
conn = lite.connect(database)
with conn:
c = conn.cursor()
if is_email:
query = "select username from userInfo where email = " + "'" + str(id) + "'"
else:
query = "select username from userInfo where username = " + "'" + str(id) + "'"
c.execute(query)
profReviews = c.fetchall()
if profReviews:
return True
else:
return False