Leave out roles array in serialized user

Leave out the roles property containing the array of role ids if the
user does not have any roles.
This commit is contained in:
Hornwitser committed 2020-09-01 17:59:19 +02:00
1 parent 9761fbb71c
commit 5e5a47ce02
2 files changed
+17 -7

No files matched your search

+4 -1
View File
@@ -173,9 +173,12 @@ class User {
serialize() {
let serialized = {
name: this.name,
roles: [...this.roles].map(role => role.id),
};
if (this.roles.size) {
serialized.roles = [...this.roles].map(role => role.id);
}
if (this.tokenValidAfter) {
serialized.tokenValidAfter = this.tokenValidAfter;
}