Skip to content

Commit

Permalink
Merge pull request #58 from NJUPT-SAST/dev-xun
Browse files Browse the repository at this point in the history
fix clientStore bug but need test
  • Loading branch information
Xunop authored Oct 25, 2023
2 parents 96664ec + 04a8375 commit e4ab6aa
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 e4ab6aa

Please sign in to comment.