working registration of hash and user
This commit is contained in:
parent
686d1de191
commit
ecd73ead15
|
@ -1,7 +1,7 @@
|
|||
import sqlite3
|
||||
from sqlite3 import Error
|
||||
|
||||
database = r"cgi-example.sqlite3"
|
||||
database = r"db/cgi-example.sqlite3"
|
||||
|
||||
def create_connection():
|
||||
""" create a database connection to the SQLite database
|
||||
|
@ -22,13 +22,13 @@ def add_user(conn):
|
|||
:param conn:
|
||||
:return: user id
|
||||
"""
|
||||
|
||||
sql = ''' INSERT INTO users
|
||||
DEFAULT VALUES '''
|
||||
sql = ''' INSERT INTO users DEFAULT VALUES '''
|
||||
cur = conn.cursor()
|
||||
cur.execute(sql)
|
||||
conn.commit()
|
||||
|
||||
try:
|
||||
cur.execute(sql)
|
||||
conn.commit()
|
||||
except:
|
||||
return 'error in insert'
|
||||
return cur.lastrowid
|
||||
|
||||
def add_hash(conn, cert_user):
|
||||
|
@ -38,12 +38,10 @@ def add_hash(conn, cert_user):
|
|||
:param cert_user:
|
||||
:return: id
|
||||
"""
|
||||
sql = ''' INSERT INTO certs(hash,user_id)
|
||||
VALUES(?,?) '''
|
||||
sql = ''' INSERT INTO certs(hash,user_id) VALUES(?,?) '''
|
||||
cur = conn.cursor()
|
||||
cur.execute(sql, cert_user)
|
||||
conn.commit()
|
||||
|
||||
return cur.lastrowid
|
||||
|
||||
def get_user(conn, tls_client_hash):
|
||||
|
@ -70,7 +68,6 @@ def check_hash(tls_client_hash):
|
|||
:param tls_client_hash:
|
||||
:return: user id
|
||||
"""
|
||||
|
||||
conn = create_connection()
|
||||
with conn:
|
||||
user_id = get_user(conn, tls_client_hash)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from helpers import get_client_cert
|
||||
from db import check_hash
|
||||
|
||||
|
|
Loading…
Reference in New Issue