The backend for the project formerly known as signet, now known as beignet.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132
  1. package endpoints
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "github.com/imosed/signet/auth"
  6. . "github.com/imosed/signet/data"
  7. )
  8. type GetUsersResponse struct {
  9. Users []User `json:"users"`
  10. }
  11. func GetUsers(w http.ResponseWriter, r *http.Request) {
  12. claims, err := auth.GetUserClaims(r)
  13. if claims.Privileges > AdminPlus {
  14. return
  15. }
  16. var users []User
  17. Db.Table("users").Where("privileges >= ?", claims.Privileges).Scan(&users)
  18. var resp GetUsersResponse
  19. resp.Users = users
  20. err = json.NewEncoder(w).Encode(resp)
  21. if err != nil {
  22. panic("Could not deliver response")
  23. }
  24. }