MW fix from hardcode
This commit is contained in:
parent
a66873d12d
commit
64a242cdea
3 changed files with 36 additions and 16 deletions
|
|
@ -4,16 +4,22 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"merch-api/internal/user"
|
||||
"merch-api/pkg/authCheck"
|
||||
"merch-api/pkg/responses"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func authMW(up user.Provider) gin.HandlerFunc {
|
||||
func authMW(up user.Provider, auth authCheck.AuthChecker, serviceId int32) gin.HandlerFunc {
|
||||
log.Debug("Auth Middleware enabled")
|
||||
return func(c *gin.Context) {
|
||||
//019caeab-aa81-7f09-a220-d7e675300638 //user_id 1
|
||||
userUuid := "019cd29b-e35b-7eb2-85c6-111ca0d15bff" //TODO placeholder for dev purposes
|
||||
log.Warnf("%v using placeholder uuid: %v", pkgLogHeader, userUuid)
|
||||
cookie, err := c.Cookie("sessionToken")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnauthorized, responses.Unauthorized{Error: err.Error()})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
userUuid, err := auth.VerifySession(c, cookie, serviceId)
|
||||
|
||||
userId, err := up.GetUserId(c, userUuid)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue