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

Method Login

services/auth.service.go:35–55  ·  view source on GitHub ↗

Login function

(email string, cleanPassword string, refreshToken bool)

Source from the content-addressed store, hash-verified

33
34// Login function
35func (authService *AuthService) Login(email string, cleanPassword string, refreshToken bool) (response map[string]string, err error) {
36 user := &models.User{}
37 coll := mgm.CollectionByName("user")
38 coll.First(bson.M{"email": strings.ToLower(email), "active": true}, user)
39
40 // check password if we are not refreshing JWT token
41 if !refreshToken {
42 match := checkPasswordHash(cleanPassword, user.Password)
43 if !match {
44 return nil, errors.New("username or password invalid")
45 }
46 }
47
48 message := map[string]string{
49 "success": "true",
50 "message": "Enjoy your token!",
51 "token": generateToken(*user),
52 }
53
54 return message, err
55}
56
57// Signup function
58func (authService *AuthService) Signup(params map[string]interface{}, signupWithActivate bool) (response map[string]string, err error) {

Callers

nothing calls this directly

Calls 2

checkPasswordHashFunction · 0.85
generateTokenFunction · 0.85

Tested by

no test coverage detected