Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: /generate_link endpoint excluded from authorized email restriction #1779

Closed
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
5 changes: 5 additions & 0 deletions internal/api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func (a *API) isValidAuthorizedEmail(w http.ResponseWriter, req *http.Request) (
return ctx, nil
}

// skip checking for authorized email addresses if it's a POST request to /generate_link
if req.URL.Path == "/generate_link" && req.Method == http.MethodPost {
return ctx, nil
}

var body struct {
Email string `json:"email"`
}
Expand Down
7 changes: 7 additions & 0 deletions internal/api/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,13 @@ func (ts *MiddlewareTestSuite) TestIsValidAuthorizedEmail() {
"email": "[email protected]",
},
},
{
desc: "bypass check for generate_link endpoint",
reqPath: "/generate_link",
body: map[string]interface{}{
"email": "[email protected]",
},
},
{
desc: "bypass check if no email in request body",
reqPath: "/signup",
Expand Down