diff --git a/server/router/selfregisterroute/controller.go b/server/router/selfregisterroute/controller.go index 9edaa7c..bb5c9ab 100644 --- a/server/router/selfregisterroute/controller.go +++ b/server/router/selfregisterroute/controller.go @@ -16,6 +16,11 @@ import ( "github.com/labstack/echo" ) +const ( + notificationEmailSubject = "Registration sucessful" + notificationEmailBody = "You have registered as a Visit Reporter for CHM NEMT.\nLogin: https://portal.bcbsinstitute.com\nReset PW: https://portal.bcbsinstitute.com/forgot" +) + var ( instance *controller once sync.Once @@ -115,5 +120,15 @@ func (c *controller) handle(ctx echo.Context) error { return routeutils.HandleAPIError(ctx, err) } + fmt.Println("\n\nSend email\n\n") + //Send email notification to Authorized user + notifications := make([]viewmodel.Notification, 1) + notifications = append(notifications, viewmodel.Notification{Type: "email", From: c.cfg.Email.Sender, To: *user.Email, Subject: notificationEmailSubject, Message: notificationEmailBody}) + + notifications, err = c.svc.Notification.SendNotifications(notifications) + if err != nil { + return routeutils.HandleAPIError(ctx, err) + } + return routeutils.ResponseAPIOK(ctx, user) }