def verify_password(self, password_attempt): salt = cur.execute("SELECT salt FROM user WHERE id=?", (self.id,)).fetchone()[0] hashed = cur.execute("SELECT hash FROM user WHERE id=?", (self.id,)).fetchone()[0] if hashlib.sha512(salt + password_attempt).hexdigest() == hashed: return True else: return False
def __init__(self, user_id): self.id = uuid.uuid4().hex self.start_time = time.time() self.end_time = self.start_time + SESSION_DURATION cur.execute( 'INSERT INTO session(id, start_time, end_time, user_id) VALUES (?, ?, ?, ?)', (self.id, self.start_time, self.end_time, user_id) )
def verify_password(self, password_attempt): salt = cur.execute('SELECT salt FROM user WHERE id=?', (self.id, )).fetchone()[0] hashed = cur.execute('SELECT hash FROM user WHERE id=?', (self.id, )).fetchone()[0] if hashlib.sha512(salt + password_attempt).hexdigest() == hashed: return True else: return False
def get_tasklists(self): tasklists = [] for tasklist_id in cur.execute( 'SELECT id FROM tasklist WHERE user_id=?', (self.id, )).fetchall(): tasklists.append(Tasklist(tasklist_id[0])) return tasklists
def verify_session(session_id): if not session_id: return False current_time = time.time() end_time = cur.execute('SELECT end_time FROM session WHERE id=?', (session_id,)).fetchone()[0] if current_time > end_time: return False return True
def __init__(self, tasklist_id): self.id = tasklist_id self.name = cur.execute('SELECT name FROM tasklist WHERE id=?', (self.id,)).fetchone()[0]
def add_task(self, task_name): cur.execute('INSERT INTO task (name, tasklist_id) VALUES (?,?)', (task_name, self.id))
def get_tasks(self): tasks = [] for task_id in cur.execute('SELECT id FROM task WHERE tasklist_id=?', (self.id,)).fetchall(): tasks.append(Task(task_id[0])) return tasks
def delete(self): cur.execute('DELETE FROM tasklist WHERE id=?', (self.id,))
def edit(self, tasklist_name): cur.execute('UPDATE tasklist SET name = ? WHERE id =?', (tasklist_name, self.id))
def __init__(self, username): self.username = username self.id = cur.execute('SELECT id FROM user WHERE username=?', (self.username, )).fetchone()[0]
def __init__(self, username): self.username = username self.id = cur.execute("SELECT id FROM user WHERE username=?", (self.username,)).fetchone()[0]
def add_tasklist(self, tasklist_name): cur.execute("INSERT INTO tasklist (name, user_id) VALUES (?,?)", (tasklist_name, self.id))
def get_tasklists(self): tasklists = [] for tasklist_id in cur.execute("SELECT id FROM tasklist WHERE user_id=?", (self.id,)).fetchall(): tasklists.append(Tasklist(tasklist_id[0])) return tasklists
def drop_session(session_id): end_time = time.time() cur.execute('UPDATE session SET end_time = ? WHERE id =?', (end_time, session_id))
def refresh_session(session_id): end_time = time.time() + SESSION_DURATION cur.execute('UPDATE session SET end_time = ? WHERE id =?', (end_time, session_id))