MCPcopy Index your code
hub / github.com/dnote/dnote / login

Method login

pkg/server/controllers/users.go:147–171  ·  view source on GitHub ↗
(form LoginForm)

Source from the content-addressed store, hash-verified

145}
146
147func (u *Users) login(form LoginForm) (*database.Session, error) {
148 if form.Email == "" {
149 return nil, app.ErrEmailRequired
150 }
151 if form.Password == "" {
152 return nil, app.ErrPasswordRequired
153 }
154
155 user, err := u.app.Authenticate(form.Email, form.Password)
156 if err != nil {
157 // If the user is not found, treat it as invalid login
158 if err == app.ErrNotFound {
159 return nil, app.ErrLoginInvalid
160 }
161
162 return nil, err
163 }
164
165 s, err := u.app.SignIn(user)
166 if err != nil {
167 return nil, err
168 }
169
170 return s, nil
171}
172
173func getPathOrReferrer(path string, r *http.Request) string {
174 q := r.URL.Query()

Callers 2

LoginMethod · 0.95
V3LoginMethod · 0.95

Calls 2

AuthenticateMethod · 0.80
SignInMethod · 0.80

Tested by

no test coverage detected