add confirmation email on complete
This commit is contained in:
@@ -16,12 +16,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
tokenExpirationTime = 90 // in minutes
|
||||
randomStringLength = 15
|
||||
baseURL = "http://localhost:5000"
|
||||
passwordResetEmailSubject = "Reset Your Password"
|
||||
passwordResetEmailMainBody = "To reset your password click here or copy the following link and paste it into your browser: \n\n " + baseURL + "/#/reset-password/"
|
||||
passwordResetEmailFooter = "\nThis link expires in 90 minutes"
|
||||
tokenExpirationTime = 90 // in minutes
|
||||
randomStringLength = 15
|
||||
baseURL = "http://localhost:5000"
|
||||
passwordResetEmailSubject = "Reset Your Password"
|
||||
passwordResetEmailMainBody = "To reset your password click here or copy the following link and paste it into your browser: \n\n " + baseURL + "/#/reset-password/"
|
||||
passwordResetEmailFooter = "\nThis link expires in 90 minutes"
|
||||
passwordResetCompleteEmailSubject = "Your Password Has been Reset"
|
||||
passwordResetCompleteEmailBody = "Your password has been reset. To login click here or copy the following link and paste it into your browser: \n\n" + baseURL + "/#/login"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -88,7 +90,7 @@ func (c *controller) handleResetRequest(ctx echo.Context) error {
|
||||
notification := viewmodel.Notification{
|
||||
Type: applicationservice.NotificationTypeEmail,
|
||||
From: c.cfg.Email.Sender,
|
||||
To: "test.test.no@yandex.com",
|
||||
To: *user.Email,
|
||||
Subject: passwordResetEmailSubject,
|
||||
Message: passwordResetEmailMainBody + token + passwordResetEmailFooter,
|
||||
}
|
||||
@@ -129,11 +131,26 @@ func (c *controller) handleResetComplete(ctx echo.Context) error {
|
||||
fmt.Println(fullUserData)
|
||||
|
||||
//write new password in database
|
||||
//TODO
|
||||
|
||||
if err := c.svc.PasswordReset.SetTokenUsed(userToken); err != nil {
|
||||
routeutils.ResponseAPIPasswordResetFailed(ctx, "Reset failed")
|
||||
}
|
||||
|
||||
//Send email with reset link
|
||||
notification := viewmodel.Notification{
|
||||
Type: applicationservice.NotificationTypeEmail,
|
||||
From: c.cfg.Email.Sender,
|
||||
To: *user.Email,
|
||||
Subject: passwordResetCompleteEmailSubject,
|
||||
Message: passwordResetCompleteEmailBody,
|
||||
}
|
||||
|
||||
notification, err = c.svc.Notification.SendNotificationWithoutWritingToDatabase(notification)
|
||||
if err != nil {
|
||||
return routeutils.HandleAPIError(ctx, err)
|
||||
}
|
||||
|
||||
return routeutils.ResponseAPIOK(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user