From 21fb3c12c86fe3f03531c4f323854da36fb82628 Mon Sep 17 00:00:00 2001 From: wikiapiserver Date: Thu, 25 Jun 2026 13:10:33 +0200 Subject: fix: update queries for new refresh_token_created column and add error logging - INSERT and UPDATE now set both refresh_token_created and access_token_created timestamps - Register handler logs the actual error on failure --- db/db.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/db.go b/db/db.go index 50b1f17..059f1df 100644 --- a/db/db.go +++ b/db/db.go @@ -130,8 +130,8 @@ func (d *DB) CreateAccount(ctx context.Context, username, plaintextPW string) (* } res, err := d.conn.ExecContext(ctx, - `INSERT INTO account (username, password, refresh_token, access_token, access_token_created) - VALUES (?, ?, ?, ?, NOW())`, + `INSERT INTO account (username, password, refresh_token, access_token, refresh_token_created, access_token_created) + VALUES (?, ?, ?, ?, NOW(), NOW())`, username, plaintextPW, tokens.RefreshToken, tokens.AccessToken, @@ -199,7 +199,7 @@ func (d *DB) RotateTokens(ctx context.Context, id int64) (*Account, error) { } res, err := d.conn.ExecContext(ctx, - `UPDATE account SET refresh_token = ?, access_token = ?, access_token_created = NOW() + `UPDATE account SET refresh_token = ?, access_token = ?, refresh_token_created = NOW(), access_token_created = NOW() WHERE id = ?`, rt, at, id) if err != nil { return nil, fmt.Errorf("rotate tokens: %w", err) -- cgit v1.2.3