Gracefully handle users without an organization
This commit is contained in:
parent
961ca9270e
commit
e475e43fef
1 changed files with 7 additions and 5 deletions
|
|
@ -96,15 +96,17 @@ func contentForUser(ctx context.Context, user *models.User) (User, error) {
|
|||
return User{}, err
|
||||
}
|
||||
org := user.R.Organization
|
||||
var organization Organization
|
||||
if org != nil {
|
||||
organization.ID = int(org.ID)
|
||||
organization.Name = org.Name
|
||||
}
|
||||
return User{
|
||||
DisplayName: user.DisplayName,
|
||||
Initials: extractInitials(user.DisplayName),
|
||||
Notifications: notifications,
|
||||
Organization: Organization{
|
||||
ID: int(org.ID),
|
||||
Name: org.Name,
|
||||
},
|
||||
Username: user.Username,
|
||||
Organization: organization,
|
||||
Username: user.Username,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue