Add Voucher Undian

This commit is contained in:
aditya.siregar
2025-06-06 21:14:28 +07:00
parent 54144b2eba
commit fa8f0ad380
10 changed files with 530 additions and 413 deletions
+28
View File
@@ -72,6 +72,34 @@ func CustomerAuthorizationMiddleware(cryp repository.Crypto) gin.HandlerFunc {
}
}
func OptionalCustomerAuthorizationMiddleware(cryp repository.Crypto) gin.HandlerFunc {
return func(c *gin.Context) {
tokenString := c.GetHeader("Authorization")
if tokenString == "" {
c.Next()
return
}
tokenString = strings.TrimPrefix(tokenString, "Bearer ")
claims, err := cryp.ParseAndValidateJWTCustomer(tokenString)
if err != nil {
c.Next()
return
}
customCtx, err := mycontext.NewMyContextCustomer(c.Request.Context(), claims)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "error initialize context"})
c.Next()
return
}
c.Set("myCtx", customCtx)
c.Next()
}
}
func SuperAdminMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
ctx, exists := c.Get("myCtx")