Remove domains from auth API responses

- Remove Domains field from UserResponse struct
- Login and Me endpoints no longer return domains
- Domains should be fetched separately from /api/domains
This commit is contained in:
Christoph Haas 2026-03-29 22:28:54 +02:00
parent a64989c997
commit 3198819f75

View file

@ -39,7 +39,6 @@ type UserResponse struct {
ID uint `json:"id"`
Username string `json:"username"`
Role string `json:"role"`
Domains []string `json:"domains"`
}
func (h *AuthHandler) Login(c *gin.Context) {
@ -55,14 +54,6 @@ func (h *AuthHandler) Login(c *gin.Context) {
return
}
isAdmin := user.Role.ImcUsersRole == "admin"
domains, _ := h.db.GetUserAccessibleDomains(c.Request.Context(), user.ID, isAdmin)
domainNames := make([]string, len(domains))
for i, d := range domains {
domainNames[i] = d.Name
}
token, err := h.jwtManager.GenerateToken(uint(user.ID), user.Username, string(user.Role.ImcUsersRole), 24*time.Hour)
if err != nil {
Error(c, http.StatusInternalServerError, "failed to generate token")
@ -75,7 +66,6 @@ func (h *AuthHandler) Login(c *gin.Context) {
ID: uint(user.ID),
Username: user.Username,
Role: string(user.Role.ImcUsersRole),
Domains: domainNames,
},
})
}
@ -93,19 +83,10 @@ func (h *AuthHandler) Me(c *gin.Context) {
return
}
isAdmin := user.Role.ImcUsersRole == "admin"
domains, _ := h.db.GetUserAccessibleDomains(c.Request.Context(), user.ID, isAdmin)
domainNames := make([]string, len(domains))
for i, d := range domains {
domainNames[i] = d.Name
}
Success(c, UserResponse{
ID: uint(user.ID),
Username: user.Username,
Role: string(user.Role.ImcUsersRole),
Domains: domainNames,
})
}