Skip to content

Commit 378634e

Browse files
committed
Added detail of UserPasswordResettingNotification
1 parent 581140c commit 378634e

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

15/umbraco-cms/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@
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)

15/umbraco-cms/reference/notifications/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
```

0 commit comments

Comments
 (0)