diff --git a/b0esche_cloud/lib/models/organization.dart b/b0esche_cloud/lib/models/organization.dart index 72dffdc..85c1f90 100644 --- a/b0esche_cloud/lib/models/organization.dart +++ b/b0esche_cloud/lib/models/organization.dart @@ -21,7 +21,7 @@ class Member { orgId: json['OrgID'] ?? json['orgId'], role: json['Role'] ?? json['role'], createdAt: DateTime.parse(json['CreatedAt'] ?? json['createdAt']), - user: User.fromJson(json['User'] ?? json), + user: User.fromJson(json['user']), ); } } @@ -90,7 +90,7 @@ class JoinRequest { inviteToken: json['InviteToken'] ?? json['inviteToken'], requestedAt: DateTime.parse(json['RequestedAt'] ?? json['requestedAt']), status: json['Status'] ?? json['status'], - user: User.fromJson(json['User'] ?? json), + user: User.fromJson(json['user']), ); } } diff --git a/go_cloud/internal/database/db.go b/go_cloud/internal/database/db.go index e383240..6c18a8e 100644 --- a/go_cloud/internal/database/db.go +++ b/go_cloud/internal/database/db.go @@ -63,13 +63,13 @@ func (sa StringArray) Value() (driver.Value, error) { } type User struct { - ID uuid.UUID - Email string - Username string - DisplayName string - PasswordHash *string - CreatedAt time.Time - LastLoginAt *time.Time + ID uuid.UUID `json:"id"` + Email string `json:"email"` + Username string `json:"username"` + DisplayName string `json:"displayName"` + PasswordHash *string `json:"-"` + CreatedAt time.Time `json:"createdAt"` + LastLoginAt *time.Time `json:"lastLoginAt"` } type Credential struct { diff --git a/go_cloud/internal/http/routes.go b/go_cloud/internal/http/routes.go index 610312a..af40a7a 100644 --- a/go_cloud/internal/http/routes.go +++ b/go_cloud/internal/http/routes.go @@ -897,10 +897,10 @@ type memberResponse struct { } type userInfo struct { - ID string `json:"id"` - Username string `json:"username"` - DisplayName string `json:"displayName"` - Email string `json:"email"` + ID string `json:"id"` + Username string `json:"username"` + DisplayName *string `json:"displayName"` + Email string `json:"email"` } func listMembersHandler(w http.ResponseWriter, r *http.Request, db *database.DB) { @@ -924,7 +924,12 @@ func listMembersHandler(w http.ResponseWriter, r *http.Request, db *database.DB) User: userInfo{ ID: m.User.ID.String(), Username: m.User.Username, - DisplayName: m.User.DisplayName, + DisplayName: func() *string { + if m.User.DisplayName == "" { + return nil + } + return &m.User.DisplayName + }(), Email: m.User.Email, }, }) @@ -1191,7 +1196,12 @@ func listJoinRequestsHandler(w http.ResponseWriter, r *http.Request, db *databas User: userInfo{ ID: req.User.ID.String(), Username: req.User.Username, - DisplayName: req.User.DisplayName, + DisplayName: func() *string { + if req.User.DisplayName == "" { + return nil + } + return &req.User.DisplayName + }(), Email: req.User.Email, }, })