Skip to content

Commit

Permalink
🙋
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo Arima committed Aug 18, 2024
1 parent 3b18dc3 commit d3578b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions pkg/server/controller/common_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ func (commonControllerForPublic commonControllerForPublic) CreateEmail(c *gin.Co
tempCode := commonControllerForPublic.CommonRepository.SetTempCode(model.Email{
To: userRequest.User.Email,
})
url := fmt.Sprintf("http://localhost:8080/email?code=%s", tempCode)
commonControllerForPublic.CommonRepository.CreateEmail(model.Email{
To: userRequest.User.Email,
VeryfyEmailURL: url,
})
To: userRequest.User.Email,
}, tempCode)
}

func (commonControllerForPublic commonControllerForPublic) VerifyEmail(c *gin.Context) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/server/repository/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type CommonRepository interface {
CreateEmail(email model.Email)
CreateEmail(email model.Email, tempCode string)
SetTempCode(email model.Email) string
GetTempCode(email model.Email) string
}
Expand All @@ -27,13 +27,14 @@ type commonRepository struct {
BaseConfig config.BaseConfig
}

func (commonRepository commonRepository) CreateEmail(email model.Email) {
func (commonRepository commonRepository) CreateEmail(email model.Email, tempCode string) {
tmpl, err := template.ParseFiles("pkg/server/template/verify_email.tpl")
if err != nil {
fmt.Println("Error parsing template file:", err)
return
}
email.From = commonRepository.BaseConfig.YamlConfig.Application.Server.Mail.User
email.VeryfyEmailURL = commonRepository.BaseConfig.YamlConfig.Application.Client.ServerEndpoint + "/api/public/email?code=" + tempCode

var emailContent bytes.Buffer
err = tmpl.Execute(&emailContent, email)
Expand Down

0 comments on commit d3578b9

Please sign in to comment.