Skip to content

Commit 5b836ee

Browse files
committed
fix: review comments
1 parent 8622736 commit 5b836ee

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

internal/assets/migrations/000008_oidc_coder_user.down.sql renamed to internal/assets/migrations/000008_oidc_code_reuse.down.sql

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "oidc_tokens" ADD COLUMN "code_hash" TEXT NOT NULL DEFAULT "";

internal/assets/migrations/000008_oidc_coder_user.up.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/controller/oidc_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package controller
22

33
import (
4+
"database/sql"
45
"errors"
56
"fmt"
67
"net/http"
@@ -275,9 +276,10 @@ func (controller *OIDCController) Token(c *gin.Context) {
275276
case "authorization_code":
276277
entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID)
277278
if err != nil {
278-
// Delete the access token just in case
279-
controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
280-
279+
err := controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
280+
if err != nil && !errors.Is(err, sql.ErrNoRows) {
281+
tlog.App.Error().Err(err).Msg("Failed to delete access token by code hash")
282+
}
281283
if errors.Is(err, service.ErrCodeNotFound) {
282284
tlog.App.Warn().Msg("Code not found")
283285
c.JSON(400, gin.H{

0 commit comments

Comments
 (0)