Skip to content
This repository has been archived by the owner on Feb 15, 2018. It is now read-only.

Exposed UserManager methods wrapped by AspNetIdentityManagerService #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions source/AspNetIdentity/AspNetIdentityManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,18 @@ object ParseUInt32(string sub)
if (!UInt32.TryParse(sub, out key)) return 0;
return key;
}

public virtual Task<string> GeneratePasswordResetTokenAsync(TUserKey userId)
{
return userManager.GeneratePasswordResetTokenAsync(userId);
}
public virtual Task<TUser> FindByEmailAsync(string email)
{
return userManager.FindByEmailAsync(email);
}
public virtual Task<TUser> FindByNameAsync(string userName)
{
return userManager.FindByNameAsync(userName);
}
public virtual IdentityManagerMetadata GetStandardMetadata(bool includeAccountProperties = true)
{
var update = new List<PropertyMetadata>();
Expand Down Expand Up @@ -216,7 +227,6 @@ public virtual IdentityManagerMetadata GetStandardMetadata(bool includeAccountPr
};
return meta;
}

public virtual PropertyMetadata GetMetadataForClaim(string type, string name = null, PropertyDataType dataType = PropertyDataType.String, bool required = false)
{
return PropertyMetadata.FromFunctions<TUser, string>(type, GetForClaim(type), SetForClaim(type), name, dataType, required);
Expand Down Expand Up @@ -249,7 +259,16 @@ public virtual Func<TUser, string, IdentityManagerResult> SetForClaim(string typ
return IdentityManagerResult.Success;
};
}

public virtual async Task<IdentityManagerResult> ResetPasswordAsync(string subject, string token, string newPassword)
{
TUserKey key = ConvertUserSubjectToKey(subject);
var result = await this.userManager.ResetPasswordAsync(key, token, newPassword);
if (!result.Succeeded)
{
return new IdentityManagerResult(result.Errors.First());
}
return IdentityManagerResult.Success;
}
public virtual IdentityManagerResult SetPassword(TUser user, string password)
{
var token = this.userManager.GeneratePasswordResetToken(user.Id);
Expand All @@ -260,7 +279,6 @@ public virtual IdentityManagerResult SetPassword(TUser user, string password)
}
return IdentityManagerResult.Success;
}

public virtual string GetEmail(TUser user)
{
return userManager.GetEmail(user.Id);
Expand All @@ -285,7 +303,6 @@ public virtual IdentityManagerResult SetEmail(TUser user, string email)

return IdentityManagerResult.Success;
}

public virtual string GetPhone(TUser user)
{
return userManager.GetPhoneNumber(user.Id);
Expand Down