Skip to content

Commit

Permalink
fix: token user
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc authored and ibuler committed Sep 23, 2020
1 parent 95af719 commit 67d8e95
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/httpd/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *server) middleAuth() gin.HandlerFunc {

func (s *server) middleHtmlAuth() gin.HandlerFunc {
return func(ctx *gin.Context) {
if _, ok := ctx.GetQuery("token"); ok {
if targetType, ok := ctx.GetQuery("type"); ok && targetType == TokenTargetType {
ctx.Next()
return
}
Expand Down Expand Up @@ -115,7 +115,8 @@ func (s *server) middleDebugAuth() gin.HandlerFunc {
}

func (s *server) checkTokenValid(ctx *gin.Context) bool {
if token, ok := ctx.GetQuery("token"); ok {
if targetType, ok := ctx.GetQuery("type"); ok && targetType == TokenTargetType {
token, _ := ctx.GetQuery("target_id")
if tokenUser := service.GetTokenAsset(token); tokenUser.UserID != "" {
if currentUser := service.GetUserDetail(tokenUser.UserID); currentUser != nil {
ctx.Set(ginCtxUserKey, currentUser)
Expand Down

0 comments on commit 67d8e95

Please sign in to comment.