改名 types 为 models
This commit is contained in:
parent
8a29fc1875
commit
8231060f30
@ -5,7 +5,7 @@ import (
|
||||
"framework_v2/consts"
|
||||
"framework_v2/internal/providers"
|
||||
"framework_v2/internal/providers/jwks"
|
||||
"framework_v2/types"
|
||||
"framework_v2/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.uber.org/zap"
|
||||
@ -29,9 +29,9 @@ func NewAuthLogic() *AuthLogic {
|
||||
return &AuthLogic{}
|
||||
}
|
||||
|
||||
func (a *AuthLogic) GinMiddlewareAuth(tokenType types.JWTTokenTypes, c *gin.Context) (*types.User, error) {
|
||||
func (a *AuthLogic) GinMiddlewareAuth(tokenType models.JWTTokenTypes, c *gin.Context) (*models.User, error) {
|
||||
var sub = consts.AnonymousUser
|
||||
var jwtIdToken = &types.User{}
|
||||
var jwtIdToken = &models.User{}
|
||||
|
||||
if config.DebugMode.Enable {
|
||||
jwtIdToken.Token.Sub = sub
|
||||
@ -85,7 +85,7 @@ func (a *AuthLogic) GinMiddlewareAuth(tokenType types.JWTTokenTypes, c *gin.Cont
|
||||
return jwtIdToken, nil
|
||||
}
|
||||
|
||||
func (a *AuthLogic) GinUser(c *gin.Context) *types.User {
|
||||
func (a *AuthLogic) GinUser(c *gin.Context) *models.User {
|
||||
user, _ := c.Get(consts.AuthMiddlewareKey)
|
||||
return user.(*types.User)
|
||||
return user.(*models.User)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package grpc
|
||||
import (
|
||||
"context"
|
||||
"framework_v2/internal/providers/jwks"
|
||||
"framework_v2/types"
|
||||
"framework_v2/models"
|
||||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth"
|
||||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
@ -18,7 +18,7 @@ func JwtAuth(ctx context.Context) (context.Context, error) {
|
||||
}
|
||||
|
||||
sub := "anonymous"
|
||||
var jwtIdToken *types.User
|
||||
var jwtIdToken *models.User
|
||||
|
||||
if config.DebugMode.Enable {
|
||||
jwtIdToken.Token.Sub = sub
|
||||
|
@ -4,14 +4,14 @@ import (
|
||||
"framework_v2/consts"
|
||||
"framework_v2/internal/logic"
|
||||
"framework_v2/internal/providers/helper"
|
||||
"framework_v2/types"
|
||||
"framework_v2/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func RequireJWTIDToken(c *gin.Context) {
|
||||
auth := logic.NewAuthLogic()
|
||||
user, err := auth.GinMiddlewareAuth(types.JWTIDToken, c)
|
||||
user, err := auth.GinMiddlewareAuth(models.JWTIDToken, c)
|
||||
|
||||
if err != nil {
|
||||
c.Abort()
|
||||
|
@ -81,7 +81,7 @@ func init() {
|
||||
// switch argType {
|
||||
// case reflect.TypeOf((*gin.Context)(nil)):
|
||||
// argValue = reflect.ValueOf(c)
|
||||
// case reflect.TypeOf((*types.User)(nil)):
|
||||
// case reflect.TypeOf((*models.User)(nil)):
|
||||
// userInfo := http2.DIJWTAuth(c)
|
||||
// if userInfo == nil {
|
||||
// helper.ResponseError(c, http.StatusUnauthorized, http2.ErrNotValidToken)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package types
|
||||
package models
|
||||
|
||||
type UserTokenInfo struct {
|
||||
Exp int `json:"exp"`
|
Loading…
Reference in New Issue
Block a user