Skip to content

Commit

Permalink
added send email to Signup
Browse files Browse the repository at this point in the history
  • Loading branch information
yakuter committed Jul 18, 2020
1 parent 4e0bc93 commit 49e6abb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/passwall/passwall-server/internal/app"
"github.com/passwall/passwall-server/internal/storage"
"github.com/passwall/passwall-server/model"
"github.com/spf13/viper"
)

var (
Expand Down Expand Up @@ -77,6 +78,15 @@ func Signup(s storage.Store) http.HandlerFunc {
// 7. Create user tables in user schema
app.MigrateUserTables(s, updatedUser.Schema)

// 8. Send email to admin adbout new user subscription
subject := "PassWall New User Subscription"

body := "PassWall has new a user. User details:\n\n"
body += "Name: " + userDTO.Name + "\n"
body += "Email: " + userDTO.Email + "\n"

go app.SendMail([]string{viper.GetString("email.admin")}, subject, body)

response := model.Response{
Code: http.StatusOK,
Status: Success,
Expand Down
2 changes: 1 addition & 1 deletion internal/app/send_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ func SendMail(to []string, subject, body string) {
[]byte(message),
)
if err != nil {
log.Fatal(err)
log.Println(err)
}
}

0 comments on commit 49e6abb

Please sign in to comment.