package api import ( "errors" "net/http" "git.fabledsword.com/bvandeusen/minstrel/internal/apierror" "git.fabledsword.com/bvandeusen/minstrel/internal/auth" ) // handleGetMe returns the authenticated user's profile shape — id, // username, display_name, email, is_admin. Mirrors the response shape // of PUT /api/me/profile so the Android Settings → Profile screen can // read its starting state from a GET before the user has done a first // save. // // The full profile matters: a form seeded with display_name=null and // email=null would, on save, submit empty strings, which // handleUpdateMyProfile treats as "clear to NULL" — destroying the stored // values. The web app's narrower User type ignores the extra fields. func (h *handlers) handleGetMe(w http.ResponseWriter, r *http.Request) { user, ok := auth.UserFromContext(r.Context()) if !ok { // Hitting /me without RequireUser in front of it is a routing bug; // it can't happen in real traffic. h.logger.Error("api: /me reached without authenticated user") writeErr(w, apierror.InternalMsg("missing auth context", errors.New("missing auth context"))) return } writeJSON(w, http.StatusOK, profileViewFromUser(user)) }