Skip to content

Commit

Permalink
fix clientStore bug but need test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunop committed Oct 25, 2023
1 parent 34b088f commit 04a8375
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions api/v1/oauth_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/NJUPT-SAST/sast-link-backend/config"
reqLog "github.com/NJUPT-SAST/sast-link-backend/log"
"github.com/NJUPT-SAST/sast-link-backend/model"
"github.com/NJUPT-SAST/sast-link-backend/model/result"
"github.com/NJUPT-SAST/sast-link-backend/service"
Expand All @@ -24,16 +25,16 @@ import (
"github.com/sirupsen/logrus"
pg "github.com/vgarvardt/go-oauth2-pg/v4"
"github.com/vgarvardt/go-pg-adapter/pgx4adapter"
reqLog "github.com/NJUPT-SAST/sast-link-backend/log"
)

var (
srv *server.Server
pgxConn, _ = pgx.Connect(context.Background(), config.Config.Sub("oauth.server").GetString("db_uri"))
adapter = pgx4adapter.NewConn(pgxConn)
srv *server.Server
pgxConn, _ = pgx.Connect(context.Background(), config.Config.Sub("oauth.server").GetString("db_uri"))
tokenAdapter = pgx4adapter.NewConn(pgxConn)
// FIXME: tokenStore, clientStore maybe have some problem
tokenStore, _ = pg.NewTokenStore(adapter, pg.WithTokenStoreGCInterval(time.Minute))
clientStore, _ = pg.NewClientStore(adapter)
tokenStore, _ = pg.NewTokenStore(tokenAdapter, pg.WithTokenStoreGCInterval(time.Minute))
clientAdapter = pgx4adapter.NewConn(pgxConn)
clientStore, _ = pg.NewClientStore(clientAdapter)
)

func init() {
Expand Down Expand Up @@ -185,6 +186,8 @@ func Authorize(c *gin.Context) {
// Get code directly if user has logged in
reqLog.LogReq(r)
err = srv.HandleAuthorizeRequest(w, r)
clients, _ := srv.Manager.GetClient(r.Context(), r.Form.Get("client_id"))
log.Println(clients)
if err != nil {
c.JSON(http.StatusInternalServerError, result.Failed(result.InternalErr.Wrap(err)))
return
Expand Down

0 comments on commit 04a8375

Please sign in to comment.