fix(auth): prevent competing remember-me token rotations (#39686) (#39688)

Partially backport #39686
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-10-12 09:48:37 +00:00
1 parent 6064554b8d
commit 33aaf0cfa3
4 files changed
+54 -11

No files matched your search

+4 -3
View File
@@ -44,9 +44,10 @@ func GetAuthTokenByID(ctx context.Context, id string) (*AuthToken, error) {
return at, nil
}
func UpdateAuthTokenByID(ctx context.Context, t *AuthToken) error {
_, err := db.GetEngine(ctx).ID(t.ID).Cols("token_hash", "expires_unix").Update(t)
return err
func UpdateAuthTokenByID(ctx context.Context, t *AuthToken, oldHash string) (bool, error) {
affected, err := db.GetEngine(ctx).ID(t.ID).Where("token_hash = ?", oldHash).
Cols("token_hash", "expires_unix").Update(t)
return affected == 1, err
}
func DeleteAuthTokenByID(ctx context.Context, id string) error {