Fix initial user creation.
sqlite3.connect automatically creates a database file if it doesn't exist yet. Consequently, os.path.isfile will always return true, the auth table won't be created, and inserting a user will fail.
This commit is contained in:
parent
33c0fdcd1f
commit
d23dd0122a
@ -69,9 +69,8 @@ def adduser(username):
|
|||||||
conn = sqlite3.connect(AUTHDBPATH)
|
conn = sqlite3.connect(AUTHDBPATH)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
if not os.path.isfile(AUTHDBPATH):
|
cursor.execute( "CREATE TABLE IF NOT EXISTS auth "
|
||||||
cursor.execute( "CREATE TABLE auth "
|
"(user VARCHAR PRIMARY KEY, hash VARCHAR)")
|
||||||
"(user VARCHAR PRIMARY KEY, hash VARCHAR)")
|
|
||||||
|
|
||||||
cursor.execute("INSERT INTO auth VALUES (?, ?)", (username, hash))
|
cursor.execute("INSERT INTO auth VALUES (?, ?)", (username, hash))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user