Fix Organization Management dialog type errors

- Fix JSON key mismatch in Flutter models: change 'User' to 'user' in Member and JoinRequest fromJson
- Update backend userInfo to send displayName as *string (null when empty)
- Add json tags to database User struct for consistent lowercase keys
- Handle displayName nullability in backend handlers
This commit is contained in:
Leon Bösche
2026-01-24 02:30:15 +01:00
parent 273976a69e
commit c7e740e732
3 changed files with 25 additions and 15 deletions

View File

@@ -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']),
);
}
}

View File

@@ -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 {

View File

@@ -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,
},
})