Skip to content

Commit

Permalink
Log access denied case
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Aug 1, 2024
1 parent 481567d commit f08ad76
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions app/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"encoding/json"
"fmt"
"reflect"
"regexp"
"strings"
Expand Down Expand Up @@ -59,17 +58,14 @@ func initialCaretaker(c *fasthttp.RequestCtx, f func(md common.MethodData) commo
}
}

if md.User.UserID == 1001 {
slog.Error(fmt.Sprintf("md.User: %v\n", md.User))
}

missingPrivileges := 0
for _, privilege := range privilegesNeeded {
if uint64(md.User.TokenPrivileges)&uint64(privilege) == 0 {
missingPrivileges |= privilege
}
}
if missingPrivileges != 0 {
slog.Error("Denied access due to missing privileges", "missing", missingPrivileges, "userID", md.User.UserID, "route", string(c.Request.URI().Path()))
c.SetStatusCode(401)
mkjson(c, common.SimpleResponse(401, "Unauthorized."))
return
Expand Down

0 comments on commit f08ad76

Please sign in to comment.