MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / deleteUser

Method deleteUser

rest/admin_api.go:1920–1945  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1918}
1919
1920func (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
1947func (h *handler) deleteRole() error {
1948 h.assertAdminOnly()

Callers

nothing calls this directly

Calls 7

assertAdminOnlyMethod · 0.95
ctxMethod · 0.95
HTTPErrorfFunction · 0.92
AuditFunction · 0.92
GetUserMethod · 0.80
DeleteUserMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected