feat(api): persist and expose garmin_connected on successful auth

This commit is contained in:
2026-07-26 12:23:39 +02:00
parent 6a3f0201af
commit 002858c1cb
4 changed files with 99 additions and 7 deletions

View File

@@ -32,10 +32,11 @@ type SessionConfig struct {
}
type sessionMeResponse struct {
Name string `json:"name"`
Email string `json:"email"`
HasProfile bool `json:"has_profile"`
DisplayName string `json:"display_name,omitempty"`
Name string `json:"name"`
Email string `json:"email"`
HasProfile bool `json:"has_profile"`
DisplayName string `json:"display_name,omitempty"`
GarminConnected bool `json:"garmin_connected"`
}
func (s *Server) handleSessionLogin(w http.ResponseWriter, r *http.Request) {
@@ -113,6 +114,12 @@ func (s *Server) handleSessionMe(w http.ResponseWriter, r *http.Request) {
if u, found := userFromContext(r.Context()); found {
resp.HasProfile = true
resp.DisplayName = u.DisplayName
profile, err := s.DB.GetProfile(r.Context(), u.ID)
if err != nil {
writeError(w, http.StatusInternalServerError, err.Error())
return
}
resp.GarminConnected = profile.GarminConnectedAt != nil
}
writeJSON(w, http.StatusOK, resp)
}