Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions go/controller/send_password_reset_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"
"errors"
"log/slog"
"time"

Expand All @@ -26,12 +27,15 @@ func (ctrl *Controller) SendPasswordResetEmail( //nolint:ireturn

if !ctrl.wf.ValidateEmail(string(request.Body.Email)) {
logger.WarnContext(ctx, "email didn't pass access control checks")
return ctrl.sendError(ErrInvalidEmailPassword), nil
return api.SendPasswordResetEmail200JSONResponse(api.OK), nil
}

user, apiErr := ctrl.wf.GetUserByEmail(ctx, string(request.Body.Email), logger)
if apiErr != nil {
switch {
case errors.Is(apiErr, ErrInternalServerError):
return ctrl.respondWithError(apiErr), nil
case apiErr != nil:
return api.SendPasswordResetEmail200JSONResponse(api.OK), nil //nolint:nilerr
}

ticket := generateTicket(TicketTypePasswordReset)
Expand Down
24 changes: 4 additions & 20 deletions go/controller/send_password_reset_email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ func TestSendPasswordResetEmail(t *testing.T) { //nolint:maintidx
Options: nil,
},
},
expectedResponse: controller.ErrorResponse{
Error: "invalid-email-password",
Message: `Incorrect email or password`,
Status: 401,
},
expectedResponse: api.SendPasswordResetEmail200JSONResponse(api.OK),
expectedJWT: nil,
jwtTokenFn: nil,
getControllerOpts: []getControllerOptsFunc{},
Expand All @@ -243,11 +239,7 @@ func TestSendPasswordResetEmail(t *testing.T) { //nolint:maintidx
Options: nil,
},
},
expectedResponse: controller.ErrorResponse{
Error: "invalid-email-password",
Message: "Incorrect email or password",
Status: 401,
},
expectedResponse: api.SendPasswordResetEmail200JSONResponse(api.OK),
expectedJWT: nil,
jwtTokenFn: nil,
getControllerOpts: []getControllerOptsFunc{},
Expand Down Expand Up @@ -280,11 +272,7 @@ func TestSendPasswordResetEmail(t *testing.T) { //nolint:maintidx
Options: nil,
},
},
expectedResponse: controller.ErrorResponse{
Error: "disabled-user",
Message: "User is disabled",
Status: 401,
},
expectedResponse: api.SendPasswordResetEmail200JSONResponse(api.OK),
expectedJWT: nil,
jwtTokenFn: nil,
getControllerOpts: []getControllerOptsFunc{},
Expand Down Expand Up @@ -321,11 +309,7 @@ func TestSendPasswordResetEmail(t *testing.T) { //nolint:maintidx
Options: nil,
},
},
expectedResponse: controller.ErrorResponse{
Error: "unverified-user",
Message: "User is not verified.",
Status: 401,
},
expectedResponse: api.SendPasswordResetEmail200JSONResponse(api.OK),
expectedJWT: nil,
jwtTokenFn: nil,
getControllerOpts: []getControllerOptsFunc{},
Expand Down
Loading