()
| 1918 | } |
| 1919 | |
| 1920 | func (h *handler) deleteUser() error { |
| 1921 | h.assertAdminOnly() |
| 1922 | username := mux.Vars(h.rq)["name"] |
| 1923 | |
| 1924 | // Can't delete the guest user, only disable. |
| 1925 | if username == base.GuestUsername { |
| 1926 | return base.HTTPErrorf(http.StatusMethodNotAllowed, |
| 1927 | "The %s user cannot be deleted. Only disabled via an update.", base.GuestUsername) |
| 1928 | } |
| 1929 | |
| 1930 | user, err := h.db.Authenticator(h.ctx()).GetUser(username) |
| 1931 | if user == nil { |
| 1932 | if err == nil { |
| 1933 | err = kNotFoundError |
| 1934 | } |
| 1935 | return err |
| 1936 | } |
| 1937 | err = h.db.Authenticator(h.ctx()).DeleteUser(user) |
| 1938 | if err == nil { |
| 1939 | base.Audit(h.ctx(), base.AuditIDUserDelete, base.AuditFields{ |
| 1940 | "db": h.db.Name, |
| 1941 | "username": username, |
| 1942 | }) |
| 1943 | } |
| 1944 | return err |
| 1945 | } |
| 1946 | |
| 1947 | func (h *handler) deleteRole() error { |
| 1948 | h.assertAdminOnly() |
nothing calls this directly
no test coverage detected