MCPcopy Create free account
hub / github.com/devinterface/startersaas-go-api / ResetPassword

Method ResetPassword

services/auth.service.go:144–159  ·  view source on GitHub ↗

ResetPassword function

(token string, password string, email string)

Source from the content-addressed store, hash-verified

142
143// ResetPassword function
144func (authService *AuthService) ResetPassword(token string, password string, email string) (success bool, err error) {
145 user := &models.User{}
146 var userService = UserService{}
147 err = userService.getCollection().First(bson.M{"passwordResetToken": token, "email": email}, user)
148 if err != nil {
149 return false, err
150 }
151 if user.PasswordResetExpires.Before(time.Now()) {
152 return false, errors.New("PasswordResetToken is expired")
153 }
154 hash, _ := hashPassword(password)
155 user.Password = hash
156 user.PasswordResetToken = ""
157 err = userService.getCollection().Update(user)
158 return true, err
159}
160
161// Sso function
162func (authService *AuthService) Sso(sso string) (response map[string]string, err error) {

Callers

nothing calls this directly

Calls 3

hashPasswordFunction · 0.85
getCollectionMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected