-
-
Notifications
You must be signed in to change notification settings - Fork 429
Add unauthorised200 parameter to /user endpoint #1763
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,9 +236,21 @@ func (s *private) updateCommentCtrl(w http.ResponseWriter, r *http.Request) { | |
| render.JSON(w, r, res) | ||
| } | ||
|
|
||
| // GET /user?site=siteID - returns user info | ||
| // GET /user?site=siteID&unauthorised200=false - returns user info, with unauthorised200=true returns 200 with error message | ||
| func (s *private) userInfoCtrl(w http.ResponseWriter, r *http.Request) { | ||
| user := rest.MustGetUserInfo(r) | ||
| user, err := rest.GetUserInfo(r) | ||
| if err != nil { | ||
| if r.URL.Query().Get("unauthorised200") == "true" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the unauthorised200 parameter necessary? It looks like the frontend code will already accept a 200 response with Please correct me if I'm wrong, I'm new here, but I think if |
||
| render.JSON(w, r, R.JSON{"error": err.Error()}) | ||
| return | ||
| } | ||
| http.Error(w, "Unauthorized", http.StatusUnauthorized) | ||
| return | ||
| } | ||
|
|
||
| // as user is set, call matchSiteID middleware to verify SiteID match | ||
| matchSiteID(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})).ServeHTTP(w, r) | ||
|
|
||
| if siteID := r.URL.Query().Get("site"); siteID != "" { | ||
| user.Verified = s.dataService.IsVerified(siteID, user.ID) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this line be moved into the open routes group of handlers above, rather than creating a new group for it?