feat(deps): ✨ Add support for more departments
This commit is contained in:
parent
bdf2fac1ad
commit
4369ebb2a5
19 changed files with 296 additions and 169 deletions
|
|
@ -88,6 +88,7 @@ func ValidatePermissions(p []permissions.Permission, nextRoute http.HandlerFunc)
|
|||
for _, pm := range p {
|
||||
if !u.Permissions.IsHavePermission(pm) {
|
||||
// If not have permission response unauthorized
|
||||
fmt.Println("tried access " + fmt.Sprintf("%v", pm))
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
err := json.NewEncoder(w).Encode("Unauthorized")
|
||||
if err != nil {
|
||||
|
|
@ -106,6 +107,7 @@ func ValidateOwnerOrPermissions(p []permissions.Permission, nextRoute http.Handl
|
|||
reqUserID := chi.URLParam(r, "id")
|
||||
u := r.Context().Value("user").(*models.User)
|
||||
|
||||
fmt.Println(u)
|
||||
if reqUserID == "" {
|
||||
// If not have permission response unauthorized
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue