getAuthorities static method
Implementation
static List<UserAuthority> getAuthorities(Map<String, dynamic> jsonData) {
List<UserAuthority> authorities = (jsonData['authorities'] ?? [])
.map<UserAuthority>((authority) => UserAuthority(
id: '${jsonData['id']}_$authority',
name: '${jsonData['id']}_$authority',
authority: authority,
user: jsonData['id'],
dirty: jsonData['dirty'] ?? false))
.toList();
if (jsonData['userCredentials']?['userRoles'] != null) {
for (Map<String, dynamic> role in jsonData['userCredentials']
?['userRoles']) {
List<UserAuthority> roleAuthorities = (role['authorities'] ?? [])
.map<UserAuthority>((authority) => UserAuthority(
id: '${jsonData['id']}_$authority',
name: '${jsonData['id']}_$authority',
authority: authority,
user: jsonData['id'],
dirty: jsonData['dirty'] ?? false))
.toList();
authorities = [...authorities, ...roleAuthorities];
}
}
return authorities;
}