Fixed a duplicate SQL query, added an error handler to the CREATE GLOBAL function
This commit is contained in:
parent
42d478ec48
commit
b89a8ac83a
|
@ -203,6 +203,9 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
// Create the global table
|
||||
// Uniqueness check is a hack to ensure we only have one global row
|
||||
_, err := conn.Exec("CREATE TABLE IF NOT EXISTS global (key BLOB NOT NULL, uniquenessCheck BOOLEAN NOT NULL UNIQUE CHECK (uniquenessCheck = true) DEFAULT true)")
|
||||
if err != nil {
|
||||
logFunc(err.Error(), 3, information)
|
||||
}
|
||||
// Create the users table
|
||||
_, err = conn.Exec("CREATE TABLE IF NOT EXISTS users (id BLOB PRIMARY KEY NOT NULL UNIQUE, created INTEGER NOT NULL, username TEXT NOT NULL UNIQUE, password BLOB NOT NULL, salt BLOB NOT NULL)")
|
||||
if err != nil {
|
||||
|
@ -479,7 +482,6 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
|
||||
// Update the password
|
||||
_, err = conn.Exec("UPDATE users SET password = ?, salt = ? WHERE id = ?", hashedPassword, salt, userId)
|
||||
_, err = conn.Exec("UPDATE users SET password = ?, salt = ? WHERE id = ?", hashedPassword, salt, userId)
|
||||
if err != nil {
|
||||
renderJSON(500, w, map[string]interface{}{"error": "Internal server error", "code": "05"}, information)
|
||||
logFunc(err.Error(), 2, information)
|
||||
|
|
Loading…
Reference in New Issue