Skip to content

Instantly share code, notes, and snippets.

@xsoheilalizadeh
Created August 11, 2019 21:51
Show Gist options
  • Select an option

  • Save xsoheilalizadeh/5bcf4c079ba823649c8423d35990dbe0 to your computer and use it in GitHub Desktop.

Select an option

Save xsoheilalizadeh/5bcf4c079ba823649c8423d35990dbe0 to your computer and use it in GitHub Desktop.
ASP.NET Core Identity
public class CustomUserStore : IUserStore<IdentityUser<int>>
{
private readonly List<IdentityUser<int>> _users;
public CustomUserStore()
{
_users = new List<IdentityUser<int>>();
}
public Task<IdentityResult> CreateAsync(IdentityUser<int> user, CancellationToken cancellationToken)
{
_users.Add(user);
return Task.FromResult(IdentityResult.Success);
}
public Task<IdentityUser<int>> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
{
return Task.FromResult(_users.SingleOrDefault(u => u.NormalizedUserName == normalizedUserName));
}
/// more methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment