feat(frontend): working Discord login + signup
This commit is contained in:
parent
0e72097346
commit
c8b5b7e2c2
24 changed files with 287 additions and 119 deletions
|
@ -61,7 +61,7 @@ func (s *Server) discordCallback(w http.ResponseWriter, r *http.Request) error {
|
|||
}
|
||||
|
||||
cfg := discordOAuthConfig
|
||||
cfg.RedirectURL = decoded.CallbackDomain + "/login/discord"
|
||||
cfg.RedirectURL = decoded.CallbackDomain + "/auth/login/discord"
|
||||
token, err := cfg.Exchange(r.Context(), decoded.Code)
|
||||
if err != nil {
|
||||
log.Errorf("exchanging oauth code: %v", err)
|
||||
|
|
|
@ -105,10 +105,10 @@ func (s *Server) oauthURLs(w http.ResponseWriter, r *http.Request) error {
|
|||
|
||||
// copy Discord config and set redirect url
|
||||
discordCfg := discordOAuthConfig
|
||||
discordCfg.RedirectURL = req.CallbackDomain + "/login/discord"
|
||||
discordCfg.RedirectURL = req.CallbackDomain + "/auth/login/discord"
|
||||
|
||||
render.JSON(w, r, oauthURLsResponse{
|
||||
Discord: discordCfg.AuthCodeURL(state),
|
||||
Discord: discordCfg.AuthCodeURL(state) + "&prompt=none",
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -35,7 +35,9 @@ type PartialMember struct {
|
|||
ID xid.ID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DisplayName *string `json:"display_name"`
|
||||
Bio *string `json:"bio"`
|
||||
AvatarURLs []string `json:"avatar_urls"`
|
||||
Links []string `json:"links"`
|
||||
Names []db.FieldEntry `json:"names"`
|
||||
Pronouns []db.PronounEntry `json:"pronouns"`
|
||||
}
|
||||
|
@ -59,7 +61,9 @@ func dbUserToResponse(u db.User, fields []db.Field, members []db.Member) GetUser
|
|||
ID: members[i].ID,
|
||||
Name: members[i].Name,
|
||||
DisplayName: members[i].DisplayName,
|
||||
Bio: members[i].Bio,
|
||||
AvatarURLs: db.NotNull(members[i].AvatarURLs),
|
||||
Links: db.NotNull(members[i].Links),
|
||||
Names: db.NotNull(members[i].Names),
|
||||
Pronouns: db.NotNull(members[i].Pronouns),
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ type PatchUserRequest struct {
|
|||
}
|
||||
|
||||
// patchUser parses a PatchUserRequest and updates the user with the given ID.
|
||||
// TODO: could this be refactored to be less repetitive? names, pronouns, and fields are all validated in the same way
|
||||
func (s *Server) patchUser(w http.ResponseWriter, r *http.Request) error {
|
||||
ctx := r.Context()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue