Login function
(email string, cleanPassword string, refreshToken bool)
| 33 | |
| 34 | // Login function |
| 35 | func (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 |
| 58 | func (authService *AuthService) Signup(params map[string]interface{}, signupWithActivate bool) (response map[string]string, err error) { |
nothing calls this directly
no test coverage detected