Пример #1
0
 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
Пример #2
0
 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)
     )
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
 def __init__(self, tasklist_id):
     self.id = tasklist_id
     self.name = cur.execute('SELECT name FROM tasklist WHERE id=?', (self.id,)).fetchone()[0]
Пример #7
0
 def add_task(self, task_name):
     cur.execute('INSERT INTO task (name, tasklist_id) VALUES (?,?)', (task_name, self.id))
Пример #8
0
 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
Пример #9
0
 def delete(self):
     cur.execute('DELETE FROM tasklist WHERE id=?', (self.id,))
Пример #10
0
 def edit(self, tasklist_name):
     cur.execute('UPDATE tasklist SET name = ? WHERE id =?', (tasklist_name, self.id))
Пример #11
0
 def __init__(self, username):
     self.username = username
     self.id = cur.execute('SELECT id FROM user WHERE username=?',
                           (self.username, )).fetchone()[0]
Пример #12
0
 def __init__(self, username):
     self.username = username
     self.id = cur.execute("SELECT id FROM user WHERE username=?", (self.username,)).fetchone()[0]
Пример #13
0
 def add_tasklist(self, tasklist_name):
     cur.execute("INSERT INTO tasklist (name, user_id) VALUES (?,?)", (tasklist_name, self.id))
Пример #14
0
 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
Пример #15
0
 def drop_session(session_id):
     end_time = time.time()
     cur.execute('UPDATE session SET end_time = ? WHERE id =?', (end_time, session_id))
Пример #16
0
 def refresh_session(session_id):
     end_time = time.time() + SESSION_DURATION
     cur.execute('UPDATE session SET end_time = ? WHERE id =?', (end_time, session_id))