get refresh from context

This commit is contained in:
nquidox 2025-09-14 19:32:22 +03:00
parent a66a86a0b0
commit 4cf112ad5e
2 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import "github.com/gin-gonic/gin"
type Utils interface { type Utils interface {
IsEmail(email string) bool IsEmail(email string) bool
GetUserUuidFromContext(c *gin.Context) (string, error) GetUserUuidFromContext(c *gin.Context) (string, error)
GetRefreshUuidFromContext(c *gin.Context) (string, error)
HashPassword(password string) (string, error) HashPassword(password string) (string, error)
ComparePasswords(hashedPassword string, plainPassword string) error ComparePasswords(hashedPassword string, plainPassword string) error
} }

View file

@ -27,3 +27,22 @@ func (u *Utils) GetUserUuidFromContext(c *gin.Context) (string, error) {
} }
return userUuid.String(), nil return userUuid.String(), nil
} }
func (u *Utils) GetRefreshUuidFromContext(c *gin.Context) (string, error) {
refreshRaw, exists := c.Get("refresh_uuid")
if !exists {
return "", errors.New("refresh_uuid not found in context")
}
refreshUuidStr, ok := refreshRaw.(string)
if !ok {
return "", errors.New("refresh_uuid is not a string")
}
refreshUuid, err := uuid.Parse(refreshUuidStr)
if err != nil {
return "", errors.New("error parsing refresh_uuid")
}
return refreshUuid.String(), nil
}