fix: review comments

This commit is contained in:
Stavros
2026-04-14 12:18:55 +03:00
parent 8622736718
commit 5b836ee8c4
4 changed files with 6 additions and 4 deletions

View File

@@ -0,0 +1 @@
ALTER TABLE "oidc_tokens" ADD COLUMN "code_hash" TEXT NOT NULL DEFAULT "";

View File

@@ -1 +0,0 @@
ALTER TABLE "oidc_tokens" ADD COLUMN "code_hash" TEXT DEFAULT "";

View File

@@ -1,6 +1,7 @@
package controller package controller
import ( import (
"database/sql"
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
@@ -275,9 +276,10 @@ func (controller *OIDCController) Token(c *gin.Context) {
case "authorization_code": case "authorization_code":
entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID) entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID)
if err != nil { if err != nil {
// Delete the access token just in case err := controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code)) if err != nil && !errors.Is(err, sql.ErrNoRows) {
tlog.App.Error().Err(err).Msg("Failed to delete access token by code hash")
}
if errors.Is(err, service.ErrCodeNotFound) { if errors.Is(err, service.ErrCodeNotFound) {
tlog.App.Warn().Msg("Code not found") tlog.App.Warn().Msg("Code not found")
c.JSON(400, gin.H{ c.JSON(400, gin.H{