diff --git a/database.go b/database.go index 42b38f0..72a44f5 100644 --- a/database.go +++ b/database.go @@ -19,7 +19,7 @@ func DbInit(ctx context.Context) { panic(err) } - _, err = dbConn.Exec(ctx, `CREATE EXTENSION IF NOT EXISTS "gen_random_uuid";`) + _, err = dbConn.Exec(ctx, `CREATE EXTENSION IF NOT EXISTS "pgcrypto";`) if err != nil { panic(err) } @@ -116,14 +116,14 @@ func DbUserDelete(ctx context.Context, id uint32) error { func DbUserGetStandardInfoByName(ctx context.Context, user *User) error { err := dbConn.QueryRow(ctx, ` - SELECT id, name, pass_hash, pronouns, color_red, color_green, color_blue, created_at FROM users WHERE name = $1 + SELECT id, name, pass_hash, COALESCE(pronouns, ''), color_red, color_green, color_blue, created_at FROM users WHERE name = $1 `, user.Name).Scan(&user.Id, &user.Name, &user.PasswordHash, &user.Pronouns, &user.Color[0], &user.Color[1], &user.Color[2], &user.CreatedAt) return err } func DbUserGetById(ctx context.Context, user *User) error { err := dbConn.QueryRow(ctx, ` - SELECT name, pass_hash, pronouns, color_red, color_green, color_blue, created_at FROM users WHERE id = $1 + SELECT name, pass_hash, COALESCE(pronouns, ''), color_red, color_green, color_blue, created_at FROM users WHERE id = $1 `, user.Id).Scan(&user.Name, &user.PasswordHash, &user.Pronouns, &user.Color[0], &user.Color[1], &user.Color[2], &user.CreatedAt) return err } diff --git a/go-socket b/go-socket index 7a7816d..1880940 100755 Binary files a/go-socket and b/go-socket differ diff --git a/http.go b/http.go index 312f662..24fb619 100644 --- a/http.go +++ b/http.go @@ -514,7 +514,7 @@ func HttpHandleTokenNew(response http.ResponseWriter, request *http.Request) { return } if err = getWholeUserFromDb(ctx, user); err != nil { - http.Error(response, "internal server error", http.StatusInternalServerError) + http.Error(response, err.Error(), http.StatusInternalServerError) return } } @@ -527,13 +527,13 @@ func HttpHandleTokenNew(response http.ResponseWriter, request *http.Request) { token, err := TokenCreate(user.Id) if err != nil { - http.Error(response, "internal server error", http.StatusInternalServerError) + http.Error(response, "internal server error2", http.StatusInternalServerError) return } json, err := json2.Marshal(LoginReturn{Token: token, UserId: user.Id}) if err != nil { - http.Error(response, "internal server error", http.StatusInternalServerError) + http.Error(response, "internal server error3", http.StatusInternalServerError) return }