mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
20 lines
603 B
C#
20 lines
603 B
C#
|
#nullable enable
|
||
|
using System.Threading.Tasks;
|
||
|
using Microsoft.AspNetCore.Identity;
|
||
|
|
||
|
namespace BTCPayServer
|
||
|
{
|
||
|
public static class UserManagerExtensions
|
||
|
{
|
||
|
public async static Task<TUser?> FindByIdOrEmail<TUser>(this UserManager<TUser> userManager, string? idOrEmail) where TUser : class
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(idOrEmail))
|
||
|
return null;
|
||
|
if (idOrEmail.Contains('@'))
|
||
|
return await userManager.FindByEmailAsync(idOrEmail);
|
||
|
else
|
||
|
return await userManager.FindByIdAsync(idOrEmail);
|
||
|
}
|
||
|
}
|
||
|
}
|