auto return 204 and run request in background

This commit is contained in:
Hayden 2024-04-28 11:42:13 -05:00
parent b96fb4bb9e
commit f4c63613d5
No known key found for this signature in database
GPG key ID: 17CF79474E257545

View file

@ -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)
}
}