File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 362362 * [ Determining if an entity is new] ( reference/notifications/determining-new-entity.md )
363363 * [ MediaService Notifications Example] ( reference/notifications/mediaservice-notifications.md )
364364 * [ MemberService Notifications Example] ( reference/notifications/memberservice-notifications.md )
365+ * [ UserService Notifications Example] ( reference/notifications/userservice-notifications.md )
365366 * [ Sending Allowed Children Notification] ( reference/notifications/sendingallowedchildrennotifications.md )
366367 * [ Umbraco Application Lifetime Notifications] ( reference/notifications/umbracoapplicationlifetime-notifications.md )
367368 * [ EditorModel Notifications] ( reference/notifications/editormodel-notifications/README.md )
Original file line number Diff line number Diff line change @@ -285,5 +285,6 @@ Below you can find some articles with some examples using Notifications.
285285* [ Hot vs. cold restarts] ( hot-vs-cold-restarts.md )
286286* [ MediaService Notifications] ( mediaservice-notifications.md )
287287* [ MemberService Notifications] ( memberservice-notifications.md )
288+ * [ UserService Notifications] ( userservice-notifications.md )
288289* [ Sending Allowed Children Notification] ( sendingallowedchildrennotifications.md )
289290* [ Umbraco Application Lifetime Notifications] ( umbracoapplicationlifetime-notifications.md )
Original file line number Diff line number Diff line change 1+ ---
2+ description : Example of how to use a UserService Notification
3+ ---
4+
5+ # UserService Notifications
6+
7+ The UserService implements ` IUserService ` and provides access to operations involving ` IUser ` .
8+
9+ The following example illustrates how the password reset feature can be cancelled for a given set of users.
10+
11+ ## Usage
12+
13+ ``` csharp
14+ using Umbraco .Cms .Core .Events ;
15+ using Umbraco .Cms .Core .Notifications ;
16+
17+ namespace MySite ;
18+
19+ public class UserPasswordResettingNotificationHandler : INotificationHandler <UserPasswordResettingNotification >
20+ {
21+ public void Handle (UserPasswordResettingNotification notification )
22+ {
23+ if (notification .User .Name ? .Contains (" Eddie" ) ?? false )
24+ {
25+ notification .CancelOperation (new EventMessage (" fail" , " Can't reset password for users with name containing 'Eddie'" ));
26+ }
27+ }
28+ }
29+ ```
You can’t perform that action at this time.
0 commit comments