You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
557 B

package authentication
import (
"fmt"
"git.devices.local/mawas/golang-api-skeleton/lib/apperrors"
"git.devices.local/mawas/golang-api-skeleton/lib/response"
"github.com/gin-gonic/gin"
)
// Authorized blocks unauthorized requestors
func Authorized(c *gin.Context) {
var resp response.Envelope
userID, exists := c.Get("userID")
if !exists {
e := apperrors.NewError(apperrors.Unauthorized, "")
c.AbortWithStatusJSON(e.GetHTTPStatus(), resp.AppendError(e))
return
}
fmt.Println("permission check", userID)
// TODO add cache perm check here
}