From f4c63613d5330f774c3bb7cdba967fe1fa359f3e Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:42:13 -0500 Subject: [PATCH] auto return 204 and run request in background --- backend/app/api/handlers/v1/v1_ctrl_user.go | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_user.go b/backend/app/api/handlers/v1/v1_ctrl_user.go index 427fe43..7c9f577 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_user.go +++ b/backend/app/api/handlers/v1/v1_ctrl_user.go @@ -1,6 +1,7 @@ package v1 import ( + "context" "fmt" "net/http" @@ -169,15 +170,18 @@ func (ctrl *V1Controller) HandleUserRequestPasswordReset() errchain.HandlerFunc return err } - err = ctrl.svc.User.RequestPasswordReset(r.Context(), v) - if err != nil { - log.Err(err).Msg("failed to request password reset") - return server.Error(). - Msg("unknow error occurred"). - Status(http.StatusInternalServerError). - Write(r.Context(), w) - } + go func() { + ctx := context.Background() - return nil + err = ctrl.svc.User.RequestPasswordReset(ctx, v) + if err != nil { + log.Warn(). + Err(err). + Str("email", v.Email). + Msg("failed to request password reset") + } + }() + + return server.JSON(w, http.StatusNoContent, nil) } }