added comments
This commit is contained in:
@ -14,6 +14,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// GetUsers retrieves all users from the database and returns them as a JSON response.
|
||||
func (s *Service) GetUsers(w http.ResponseWriter, r *http.Request) {
|
||||
var users []model.User
|
||||
|
||||
@ -32,6 +33,7 @@ func (s *Service) GetUsers(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
// SetUserRole handles updating a user's role based on a UUID from the request.
|
||||
func (s *Service) SetUserRole(w http.ResponseWriter, r *http.Request) {
|
||||
var role model.Role
|
||||
userUUIDstr, ok := mux.Vars(r)["userUUID"]
|
||||
@ -63,6 +65,7 @@ func (s *Service) SetUserRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// DeleteUser handles the deletion of a user from the database, enforcing authorization checks.
|
||||
func (s *Service) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
claims, ok := auth.ExtractClaims(r.Context())
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user