fix(auth): GetProfile reads the user row — the JWT context stub has no theme
GetProfile returned the theme from the JWT-claims context stub, which carries only id/email/username/role — user.Theme was always empty, so the profile response omitted the field and the app's account-theme read-back (SERVER sync mode) could never see the stored theme. GetProfile now loads the full user row by id (h.db.GetUser).
This commit is contained in:
@@ -486,7 +486,14 @@ window.location.href = '%s';
|
|||||||
|
|
||||||
// GetProfile handles GET /api/auth/profile
|
// GetProfile handles GET /api/auth/profile
|
||||||
func (h *AuthHandler) GetProfile(c *echo.Context) error {
|
func (h *AuthHandler) GetProfile(c *echo.Context) error {
|
||||||
user := MustGetAuthenticatedUser(c)
|
ctxUser := MustGetAuthenticatedUser(c)
|
||||||
|
// The context user is a JWT-claims stub (id/email/username/role) —
|
||||||
|
// it carries no theme. Read the full row: clients (the Android app)
|
||||||
|
// sync their app-chrome theme from this field.
|
||||||
|
user, err := h.db.GetUser(c.Request().Context(), ctxUser.ID)
|
||||||
|
if err != nil {
|
||||||
|
return c.JSON(http.StatusInternalServerError, map[string]string{"error": "failed to load profile"})
|
||||||
|
}
|
||||||
|
|
||||||
firstName := ""
|
firstName := ""
|
||||||
if user.FirstName.Valid {
|
if user.FirstName.Valid {
|
||||||
|
|||||||
Reference in New Issue
Block a user