private static void SetUserRoleAndPermissionClaims(IUser user, ClaimsBuilder builder) { foreach (string roleName in user.Roles.Select(r => r.Name).Distinct()) { if (roleName != null) { builder.AddRole(roleName); } } IEnumerable <IPermission> permissions = user.Roles.SelectMany(r => r.Permissions); foreach (string permissionName in permissions.Select(p => p.Name).Distinct()) { if (permissionName != null) { builder.AddPermission(permissionName); } } }