online-order/api/middlewares/middlewares.go

29 lines
792 B
Go
Raw Normal View History

2023-10-27 09:51:58 +00:00
package middlewares
type controller struct {
2023-10-29 23:33:40 +00:00
//service domain.AuthService
2023-10-27 09:51:58 +00:00
}
2023-10-29 23:33:40 +00:00
//func NewMiddlewareControllers(svc domain.AuthService) *controller {
// return &controller{
// service: svc,
// }
//}
//
//func (cont *controller) JwAuthtMiddleware() gin.HandlerFunc {
// return func(c *gin.Context) {
// user_id, err := jwttoken.IsTokenValid(c)
// if err != nil {
// c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized. Please Login first", "code": 401, "details": err.Error()})
// return
// }
//
// user, _, err := cont.service.GetByID(user_id)
// if err != nil || user == nil {
// c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"message": "Unauthorized. User not found", "code": 401, "details": err.Error()})
// return
// }
// c.Next()
// }
//}