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

Method getUserFromSessionRequestBody

rest/session_api.go:87–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87func (h *handler) getUserFromSessionRequestBody() (auth.User, error) {
88
89 var params struct {
90 Name string `json:"name"`
91 Password string `json:"password"`
92 }
93 err := h.readJSONInto(&params)
94 if err != nil {
95 return nil, err
96 }
97
98 var user auth.User
99 user, err = h.db.Authenticator(h.ctx()).GetUser(params.Name)
100 if err != nil {
101 return nil, err
102 }
103
104 if user == nil {
105 base.InfofCtx(h.ctx(), base.KeyAuth, "Couldn't create session for user %q: not found", base.UD(params.Name))
106 return nil, nil
107 }
108
109 authenticated, reason := user.AuthenticateWithReason(params.Password)
110 if !authenticated {
111 base.InfofCtx(h.ctx(), base.KeyAuth, "Couldn't create session for user %q: %s", base.UD(params.Name), reason)
112 return nil, nil
113 }
114
115 return user, nil
116}
117
118// DELETE /_session logs out the current session
119func (h *handler) handleSessionDELETE() error {

Callers 1

handleSessionPOSTMethod · 0.95

Calls 7

readJSONIntoMethod · 0.95
ctxMethod · 0.95
InfofCtxFunction · 0.92
UDFunction · 0.92
GetUserMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected