first commit -push
This commit is contained in:
41
RobotNet.IdentityServer/Services/UserInfoService.cs
Normal file
41
RobotNet.IdentityServer/Services/UserInfoService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace RobotNet.IdentityServer.Services;
|
||||
|
||||
public class UserInfoService
|
||||
{
|
||||
|
||||
private readonly List<Func<Task>> _handlers = [];
|
||||
|
||||
|
||||
public void RegisterHandler(Func<Task> handler)
|
||||
{
|
||||
if (handler != null && !_handlers.Contains(handler))
|
||||
{
|
||||
_handlers.Add(handler);
|
||||
}
|
||||
}
|
||||
public void UnregisterHandler(Func<Task> handler)
|
||||
{
|
||||
if (handler != null && _handlers.Contains(handler))
|
||||
{
|
||||
_handlers.Remove(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task NotifyUserInfoChanged()
|
||||
{
|
||||
var handlers = new List<Func<Task>>(_handlers);
|
||||
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
try
|
||||
{
|
||||
await handler();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error in user info change handler: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user