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

Method SendActivationEmail

services/email.service.go:39–65  ·  view source on GitHub ↗

SendActivationEmail function

(q bson.M)

Source from the content-addressed store, hash-verified

37
38// SendActivationEmail function
39func (emailService *EmailService) SendActivationEmail(q bson.M) (success bool, err error) {
40 user := &models.User{}
41 var userService = UserService{}
42 q["active"] = false
43 err = userService.getCollection().First(q, user)
44 if err != nil {
45 return false, err
46 }
47 p, _ := rand.Prime(rand.Reader, 20)
48 user.ConfirmationToken = fmt.Sprintf("%d", p)
49 err = userService.getCollection().Update(user)
50 if err != nil {
51 return false, err
52 }
53
54 engine := liquid.NewEngine()
55 emailModel, _ := loadEmail("activationLink", user.Language)
56
57 bindings := map[string]interface{}{
58 "email": user.Email,
59 "confirmationToken": user.ConfirmationToken,
60 }
61 result, err := engine.ParseAndRenderString(string(emailModel.Body), bindings)
62
63 err = SendMail(os.Getenv("DEFAULT_EMAIL_FROM"), emailModel.Subject, result, []string{user.Email})
64 return true, err
65}
66
67// SendForgotPasswordEmail function
68func (emailService *EmailService) SendForgotPasswordEmail(q bson.M) (success bool, err error) {

Callers 2

SendActivationLinkMethod · 0.80
SignupMethod · 0.80

Calls 4

loadEmailFunction · 0.85
SendMailFunction · 0.85
getCollectionMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected