Skip to content

Commit

Permalink
Adds the User related Webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
warrenbuckley committed Nov 21, 2023
1 parent 362d36f commit 5c6eb4a
Show file tree
Hide file tree
Showing 17 changed files with 422 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Group Permissions Assigned")]
public class AssignedUserGroupPermissionsWebhookEvent : WebhookEventBase<AssignedUserGroupPermissionsNotification>
{
public AssignedUserGroupPermissionsWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "assignedUserGroupPermissions";

public override object? ConvertNotificationToRequestPayload(AssignedUserGroupPermissionsNotification notification)
=> notification.EntityPermissions;
}
39 changes: 39 additions & 0 deletions src/Umbraco.Core/Webhooks/Events/User/UserDeletedWebhookEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Deleted")]
public class UserDeletedWebhookEvent : WebhookEventBase<UserDeletedNotification>
{
public UserDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userDeleted";

public override object? ConvertNotificationToRequestPayload(UserDeletedNotification notification)
{
// TODO: Map more stuff here
var result = notification.DeletedEntities.Select(entity => new
{
entity.Id,
entity.Key,
entity.Name,
entity.Language,
entity.Email,
entity.Username,
entity.FailedPasswordAttempts
});

return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Forgot Password Requested")]
public class UserForgotPasswordRequestedWebhookEvent : WebhookEventBase<UserForgotPasswordRequestedNotification>
{
public UserForgotPasswordRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userForgotPasswordRequested";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Forgotten Password Requested")]
public class UserForgottenPasswordRequestedWebhookEvent : WebhookEventBase<UserForgotPasswordRequestedNotification>
{
public UserForgottenPasswordRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userForgottenPasswordRequested";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Group Deleted")]
public class UserGroupDeletedWebhookEvent : WebhookEventBase<UserGroupDeletedNotification>
{
public UserGroupDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userGroupDeleted";

public override object? ConvertNotificationToRequestPayload(UserGroupDeletedNotification notification) => notification.DeletedEntities;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Group Saved")]
public class UserGroupSavedWebhookEvent : WebhookEventBase<UserGroupSavedNotification>
{
public UserGroupSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userGroupSaved";

public override object? ConvertNotificationToRequestPayload(UserGroupSavedNotification notification) => notification.SavedEntities;
}
22 changes: 22 additions & 0 deletions src/Umbraco.Core/Webhooks/Events/User/UserLockedWebhookEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Locked")]
public class UserLockedWebhookEvent : WebhookEventBase<UserLockedNotification>
{
public UserLockedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userLocked";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Login Failed")]
public class UserLoginFailedWebhookEvent : WebhookEventBase<UserLoginFailedNotification>
{
public UserLoginFailedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userLoginFailed";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Login Requires Verification")]
public class UserLoginRequiresVerificationWebhookEvent : WebhookEventBase<UserLoginRequiresVerificationNotification>
{
public UserLoginRequiresVerificationWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userLoginRequiresVerification";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Login Success")]
public class UserLoginSuccessWebhookEvent : WebhookEventBase<UserLoginSuccessNotification>
{
public UserLoginSuccessWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userLoginSuccess";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Login Success")]
public class UserLogoutSuccessWebhookEvent : WebhookEventBase<UserLogoutSuccessNotification>
{
public UserLogoutSuccessWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userLogoutSuccess";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Password Changed")]
public class UserPasswordChangedWebhookEvent : WebhookEventBase<UserPasswordChangedNotification>
{
public UserPasswordChangedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userPasswordChanged";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Password Reset")]
public class UserPasswordResetWebhookEvent : WebhookEventBase<UserPasswordResetNotification>
{
public UserPasswordResetWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userPasswordReset";
}
39 changes: 39 additions & 0 deletions src/Umbraco.Core/Webhooks/Events/User/UserSavedWebhookEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Saved")]
public class UserSavedWebhookEvent : WebhookEventBase<UserSavedNotification>
{
public UserSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userSaved";

public override object? ConvertNotificationToRequestPayload(UserSavedNotification notification)
{
// TODO: Map more stuff here
var result = notification.SavedEntities.Select(entity => new
{
entity.Id,
entity.Key,
entity.Name,
entity.Language,
entity.Email,
entity.Username,
entity.FailedPasswordAttempts
});

return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;

namespace Umbraco.Cms.Core.Webhooks.Events.User;

[WebhookEvent("User Two Factor Requested")]
public class UserTwoFactorRequestedWebhookEvent : WebhookEventBase<UserTwoFactorRequestedNotification>
{
public UserTwoFactorRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}

public override string Alias => "userTwoFactorRequested";

}
Loading

0 comments on commit 5c6eb4a

Please sign in to comment.