mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 08:17:23 +08:00
Prevent crash if user's groups aren't loaded. closes flarum/core#173
This commit is contained in:
parent
e2a4cf5ccb
commit
bb04eada7a
@ -63,8 +63,10 @@ export default class User extends mixin(Model, {
|
||||
*/
|
||||
badges() {
|
||||
const items = new ItemList();
|
||||
const groups = this.groups();
|
||||
|
||||
this.groups().forEach(group => {
|
||||
if (groups) {
|
||||
groups.forEach(group => {
|
||||
const name = group.nameSingular();
|
||||
|
||||
items.add('group' + group.id(),
|
||||
@ -75,6 +77,7 @@ export default class User extends mixin(Model, {
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user