From 3917892c58cc4314ceeab102837728f21bf61287 Mon Sep 17 00:00:00 2001 From: Cam Otts Date: Fri, 20 Jan 2023 10:04:52 -0600 Subject: [PATCH] missed bad request for password reset request --- controller/forgetPassword.go | 4 +- .../account/forgot_password_responses.go | 57 +++++++++++++++++++ rest_server_zrok/embedded_spec.go | 6 ++ .../account/forgot_password_responses.go | 25 ++++++++ specs/zrok.yml | 2 + 5 files changed, 92 insertions(+), 2 deletions(-) diff --git a/controller/forgetPassword.go b/controller/forgetPassword.go index bb396526..aabfd384 100644 --- a/controller/forgetPassword.go +++ b/controller/forgetPassword.go @@ -17,11 +17,11 @@ func newForgetPasswordHandler() *forgetPasswordHandler { func (handler *forgetPasswordHandler) Handle(params account.ForgotPasswordParams) middleware.Responder { if params.Body == nil || params.Body.Email == "" { logrus.Errorf("missing email") - return account.NewInviteBadRequest() + return account.NewForgotPasswordBadRequest() } if !util.IsValidEmail(params.Body.Email) { logrus.Errorf("'%v' is not a valid email address", params.Body.Email) - return account.NewInviteBadRequest() + return account.NewForgotPasswordBadRequest() } logrus.Infof("received forgot password request for email '%v'", params.Body.Email) var token string diff --git a/rest_client_zrok/account/forgot_password_responses.go b/rest_client_zrok/account/forgot_password_responses.go index 5466b428..160b35ed 100644 --- a/rest_client_zrok/account/forgot_password_responses.go +++ b/rest_client_zrok/account/forgot_password_responses.go @@ -26,6 +26,12 @@ func (o *ForgotPasswordReader) ReadResponse(response runtime.ClientResponse, con return nil, err } return result, nil + case 400: + result := NewForgotPasswordBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 500: result := NewForgotPasswordInternalServerError() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -88,6 +94,57 @@ func (o *ForgotPasswordCreated) readResponse(response runtime.ClientResponse, co return nil } +// NewForgotPasswordBadRequest creates a ForgotPasswordBadRequest with default headers values +func NewForgotPasswordBadRequest() *ForgotPasswordBadRequest { + return &ForgotPasswordBadRequest{} +} + +/* +ForgotPasswordBadRequest describes a response with status code 400, with default header values. + +forgot password request not created +*/ +type ForgotPasswordBadRequest struct { +} + +// IsSuccess returns true when this forgot password bad request response has a 2xx status code +func (o *ForgotPasswordBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this forgot password bad request response has a 3xx status code +func (o *ForgotPasswordBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this forgot password bad request response has a 4xx status code +func (o *ForgotPasswordBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this forgot password bad request response has a 5xx status code +func (o *ForgotPasswordBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this forgot password bad request response a status code equal to that given +func (o *ForgotPasswordBadRequest) IsCode(code int) bool { + return code == 400 +} + +func (o *ForgotPasswordBadRequest) Error() string { + return fmt.Sprintf("[POST /forgotPassword][%d] forgotPasswordBadRequest ", 400) +} + +func (o *ForgotPasswordBadRequest) String() string { + return fmt.Sprintf("[POST /forgotPassword][%d] forgotPasswordBadRequest ", 400) +} + +func (o *ForgotPasswordBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + // NewForgotPasswordInternalServerError creates a ForgotPasswordInternalServerError with default headers values func NewForgotPasswordInternalServerError() *ForgotPasswordInternalServerError { return &ForgotPasswordInternalServerError{} diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index f99f0a8e..ac40ce6b 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -241,6 +241,9 @@ func init() { "201": { "description": "forgot password request created" }, + "400": { + "description": "forgot password request not created" + }, "500": { "description": "internal server error" } @@ -1484,6 +1487,9 @@ func init() { "201": { "description": "forgot password request created" }, + "400": { + "description": "forgot password request not created" + }, "500": { "description": "internal server error" } diff --git a/rest_server_zrok/operations/account/forgot_password_responses.go b/rest_server_zrok/operations/account/forgot_password_responses.go index fbbb2edb..5f9b2b1c 100644 --- a/rest_server_zrok/operations/account/forgot_password_responses.go +++ b/rest_server_zrok/operations/account/forgot_password_responses.go @@ -36,6 +36,31 @@ func (o *ForgotPasswordCreated) WriteResponse(rw http.ResponseWriter, producer r rw.WriteHeader(201) } +// ForgotPasswordBadRequestCode is the HTTP code returned for type ForgotPasswordBadRequest +const ForgotPasswordBadRequestCode int = 400 + +/* +ForgotPasswordBadRequest forgot password request not created + +swagger:response forgotPasswordBadRequest +*/ +type ForgotPasswordBadRequest struct { +} + +// NewForgotPasswordBadRequest creates ForgotPasswordBadRequest with default headers values +func NewForgotPasswordBadRequest() *ForgotPasswordBadRequest { + + return &ForgotPasswordBadRequest{} +} + +// WriteResponse to the client +func (o *ForgotPasswordBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + // ForgotPasswordInternalServerErrorCode is the HTTP code returned for type ForgotPasswordInternalServerError const ForgotPasswordInternalServerErrorCode int = 500 diff --git a/specs/zrok.yml b/specs/zrok.yml index 417cbb09..0dfeb0d6 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -28,6 +28,8 @@ paths: responses: 201: description: forgot password request created + 400: + description: forgot password request not created 500: description: internal server error