Skip to content

Commit

Permalink
fix(server): clear captcha only after a successful command
Browse files Browse the repository at this point in the history
  • Loading branch information
bastean committed Feb 17, 2025
1 parent 9902916 commit 205acdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/app/server/handler/user/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ func Create(c *gin.Context) {
return
}

captcha.Clear(data.CaptchaID)

err = command.Bus.Dispatch(messages.New(
create.CommandKey,
&create.CommandAttributes{
Expand All @@ -56,6 +54,8 @@ func Create(c *gin.Context) {
return
}

captcha.Clear(data.CaptchaID)

c.JSON(http.StatusCreated, &reply.JSON{
Success: true,
Message: "Account created",
Expand Down
4 changes: 2 additions & 2 deletions internal/app/server/handler/user/forgot.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ func Forgot(c *gin.Context) {
return
}

captcha.Clear(data.CaptchaID)

err = command.Bus.Dispatch(messages.New(
forgot.CommandKey,
&forgot.CommandAttributes{
Expand All @@ -53,6 +51,8 @@ func Forgot(c *gin.Context) {
return
}

captcha.Clear(data.CaptchaID)

c.JSON(http.StatusOK, &reply.JSON{
Success: true,
Message: "Link sent. Please check your inbox",
Expand Down

0 comments on commit 205acdd

Please sign in to comment.