| 37 | } |
| 38 | |
| 39 | func getUser(_ http.ResponseWriter, r *http.Request) (*modifyUserRequest, error) { |
| 40 | if r.Body == nil { |
| 41 | return nil, fberrors.ErrEmptyRequest |
| 42 | } |
| 43 | |
| 44 | req := &modifyUserRequest{} |
| 45 | err := json.NewDecoder(r.Body).Decode(req) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | |
| 50 | if req.What != "user" { |
| 51 | return nil, fberrors.ErrInvalidDataType |
| 52 | } |
| 53 | |
| 54 | return req, nil |
| 55 | } |
| 56 | |
| 57 | func withSelfOrAdmin(fn handleFunc) handleFunc { |
| 58 | return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { |