Skip to content

Commit

Permalink
fix: generate signup link should not error (#1514)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* Fixes an error introduced in #1377 where generating a signup link for
a new user results in a "User with this email not found" error

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.
  • Loading branch information
kangmingtay committed Apr 3, 2024
1 parent c0bc37b commit 4fc3881
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/api/mail.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package api

import (
mail "github.com/supabase/auth/internal/mailer"
"net/http"
"strings"
"time"

mail "github.com/supabase/auth/internal/mailer"

"github.com/badoux/checkmail"
"github.com/fatih/structs"
"github.com/pkg/errors"
Expand Down Expand Up @@ -72,8 +73,7 @@ func (a *API) adminGenerateLink(w http.ResponseWriter, r *http.Request) error {
// password generation must always succeed
panic(err)
}

default:
case mail.RecoveryVerification, mail.EmailChangeCurrentVerification, mail.EmailChangeNewVerification:
return notFoundError(ErrorCodeUserNotFound, "User with this email not found")
}
} else {
Expand Down
14 changes: 13 additions & 1 deletion internal/api/mail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,19 @@ func (ts *MailTestSuite) TestGenerateLink() {
ExpectedResponse map[string]interface{}
}{
{
Desc: "Generate signup link",
Desc: "Generate signup link for new user",
Body: GenerateLinkParams{
Email: "new_user@example.com",
Password: "secret123",
Type: "signup",
},
ExpectedCode: http.StatusOK,
ExpectedResponse: map[string]interface{}{
"redirect_to": ts.Config.SiteURL,
},
},
{
Desc: "Generate signup link for existing user",
Body: GenerateLinkParams{
Email: "test@example.com",
Password: "secret123",
Expand Down

0 comments on commit 4fc3881

Please sign in to comment.