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

Method Authenticate

pkg/server/app/users.go:131–143  ·  view source on GitHub ↗

Authenticate authenticates a user

(email, password string)

Source from the content-addressed store, hash-verified

129
130// Authenticate authenticates a user
131func (a *App) Authenticate(email, password string) (*database.User, error) {
132 user, err := a.GetUserByEmail(email)
133 if err != nil {
134 return nil, err
135 }
136
137 err = bcrypt.CompareHashAndPassword([]byte(user.Password.String), []byte(password))
138 if err != nil {
139 return nil, ErrLoginInvalid
140 }
141
142 return user, nil
143}
144
145// UpdateUserPassword updates a user's password with validation
146func UpdateUserPassword(db *gorm.DB, user *database.User, newPassword string) error {

Callers 1

loginMethod · 0.80

Calls 1

GetUserByEmailMethod · 0.95

Tested by

no test coverage detected