You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -375,6 +374,46 @@ public class DatabaseUserPolicyHandler : IUserPolicyHandler
375
374
}
376
375
```
377
376
377
+
#### Enhancing Your `HasPermission` Checks
378
+
379
+
The method `GetUserPermissions()` method requires all permissions for a user to be returned. When using a database, you might want to enhance the permformance of this call. You can do this by having your db use an `Exists` operation. To do this, you can implement the `HasPermission` method on your `UserPolicyHandler`. For example:
Copy file name to clipboardExpand all lines: src/HeimGuard/IUserPolicyHandler.cs
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
namespaceHeimGuard
2
2
{
3
3
usingSystem.Collections.Generic;
4
+
usingSystem.Linq;
5
+
usingSystem.Threading;
4
6
usingSystem.Threading.Tasks;
5
7
6
8
/// <summary>
@@ -11,7 +13,13 @@ public interface IUserPolicyHandler
11
13
/// <summary>
12
14
/// Returns an IEnumerable of strings that represents a distinct list of a given user's permissions.
13
15
/// </summary>
14
-
/// <returns><see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the list of peermissions for the current user..</returns>
16
+
/// <returns><see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the list of permissions for the current user.</returns>
15
17
Task<IEnumerable<string>>GetUserPermissions();
18
+
19
+
/// <summary>
20
+
/// Returns a boolean value indicating whether the current user has the specified permission.
21
+
/// </summary>
22
+
/// <returns><see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing a boolean indicating whether the current user has the specified permission.</returns>
0 commit comments