feat: dynamic user based roles

This commit is contained in:
2025-06-04 19:11:01 +02:00
parent 98ae3e06e9
commit 11ac92a026

View File

@ -76,6 +76,12 @@ func (h *OAuthHandler) tokenEndpoint(w http.ResponseWriter, r *http.Request) {
return
}
var roles = []string{"user"}
if user.IsAdmin {
roles = append(roles, "admin")
}
claims := types.ApiClaims{
Email: user.Email,
// TODO:
@ -83,7 +89,7 @@ func (h *OAuthHandler) tokenEndpoint(w http.ResponseWriter, r *http.Request) {
Name: user.FullName,
Picture: user.ProfilePicture,
Nonce: nonce,
Roles: []string{"user", "admin"},
Roles: roles,
RegisteredClaims: jwt.RegisteredClaims{
Issuer: h.cfg.Jwt.Issuer,
// TODO: use dedicated API id that is in local DB and bind to user there