Add UserCreated hook.

This commit is contained in:
Haiping Chen 2024-05-21 05:51:38 -05:00
parent 8eee1fd164
commit 018d889ad3
2 changed files with 7 additions and 1 deletions

View file

@ -8,4 +8,5 @@ public interface IAuthenticationHook
Task<User> Authenticate(string id, string password);
void AddClaims(List<Claim> claims);
void BeforeSending(Token token);
Task UserCreated(User user);
}

View file

@ -1,4 +1,3 @@
using BotSharp.Abstraction.Repositories;
using BotSharp.Abstraction.Users.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
@ -57,6 +56,12 @@ public class UserService : IUserService
_logger.LogWarning($"Created new user account: {record.Id} {record.UserName}");
Utilities.ClearCache();
var hooks = _services.GetServices<IAuthenticationHook>();
foreach (var hook in hooks)
{
await hook.UserCreated(record);
}
return record;
}