-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement email confirmation #80
Comments
This is a known limitation see https://github.com/Shazwazza/UmbracoIdentity/wiki/Known-Issues If you need these features, you need to extend the implementation and implement these yourself. Of course any PR would be hugely appreciated! |
Hi @Shazwazza, I am looking to implement ConfirmEmailAsync(...) in my application. I have created the following, which just inherits from the original UmbracoMembersUserManager so that I can implement ConfirmEmailAsync(...):
I am having trouble when I try to hook this up in UmbracoIdentityOwinStartup:
I have no idea how I am supposed to fulfil the arguments to that method. Can you advise? Thanks. |
Hi @Shazwazza, I am looking to implement similar functionality.
I am still getting a grip on UmbracoIdentity, and I understand AspNet Identity to an extent. I am willing to contribute these features, seems to me like essential features for Identity. Here is what I have done so far for Email Verification
So far these seem to be working able to generate a unique code and validate the code, but I want to set account active only after email verified. I am thinking of implementing |
Hi @knnithyanand,
Can you explain a little bit more about this change and why you think it's necessary? |
Hi @Shazwazza, bool IsApproved { get; set; }
bool IsLockedOut { get; set; }
DateTime LastLockoutDate { get; set; }
int FailedPasswordAttempts { get; set; } Let me know if this is not necessary or complicate things moving forward. |
Hi @knnithyanand sorry for the delay. I don't see it being necessary to implement IMembershipUser since there is no references whatsoever to this interface in this project so it's not going to add any value. If you need to add additional properties to UmbracoIdentityMember then you should just add the properties that you need and manage them appropriately which would be handled inside the UmbracoMembersUserStore. The base class I can see that the underlying method to map the values from UmbracoIdentityMember to the underlying IMember is done in the Another thing I've noticed that makes extending this a little harder is that there explicit "Support" properties like Update: I've just pushed v7.2.1 of this package which exposes these methods and adds better support for extending, see https://github.com/Shazwazza/UmbracoIdentity/releases/tag/v7.2.0 To extend this functionality and implement these additional interfaces like
ExampleCustom user store enabling the lockout feature and mapping the properties from the IMember to and from TMember. This doesn't require a custom member instance because as mentioned above most of the properties you'll need to map already exist on the underlying UmbracoIdentityMember. This also doesn't require a custom user manager because all of the methods it does just interact with the user store and the feature flag of SupportsUserLockedOut will be set based on the interfaces the user store implements. public class CustomUmbracoMembersUserStore<TMember> : UmbracoMembersUserStore<TMember>,
IUserLockoutStore<TMember, int>
where TMember : UmbracoIdentityMember, IUser<int>, new()
{
public CustomUmbracoMembersUserStore(ILogger logger, IMemberService memberService, IMemberTypeService memberTypeService, IMemberGroupService memberGroupService, IdentityEnabledMembersMembershipProvider membershipProvider, IExternalLoginStore externalLoginStore)
: base(logger, memberService, memberTypeService, memberGroupService, membershipProvider, externalLoginStore)
{
}
public Task<int> GetAccessFailedCountAsync(TMember user) => Task.FromResult(user.AccessFailedCount);
public Task<bool> GetLockoutEnabledAsync(TMember user) => Task.FromResult(user.LockoutEnabled);
public Task<DateTimeOffset> GetLockoutEndDateAsync(TMember user) => Task.FromResult(new DateTimeOffset(user.LockoutEndDateUtc ?? DateTime.MinValue));
public Task<int> IncrementAccessFailedCountAsync(TMember user)
{
user.AccessFailedCount++;
return Task.FromResult(user.AccessFailedCount);
}
public Task ResetAccessFailedCountAsync(TMember user)
{
user.AccessFailedCount = 0;
return Task.CompletedTask;
}
public Task SetLockoutEnabledAsync(TMember user, bool enabled)
{
user.LockoutEnabled = enabled;
return Task.CompletedTask;
}
public Task SetLockoutEndDateAsync(TMember user, DateTimeOffset lockoutEnd)
{
user.LockoutEndDateUtc = lockoutEnd.UtcDateTime;
return Task.CompletedTask;
}
/// <summary>
/// Override to map custom properties for persistence
/// </summary>
/// <param name="member"></param>
/// <param name="user"></param>
/// <returns></returns>
protected override bool UpdateMemberProperties(IMember member, TMember user)
{
var hasChanged = base.UpdateMemberProperties(member, user);
// Assumes your lockoutEnabled member type property is a true/false property type, in which case
// i "think" it stores 0 or 1 as a int (could be wrong though)
var lockoutEnabled = member.GetValue<int>("lockoutEnabled") == 1;
if (lockoutEnabled != user.LockoutEnabled)
{
member.SetValue("lockoutEnabled", user.LockoutEnabled ? 1 : 0);
hasChanged = true;
}
return hasChanged;
}
/// <summary>
/// Override to map custom properties when retrieved from the DB
/// </summary>
/// <param name="member"></param>
/// <returns></returns>
protected override TMember MapFromMember(IMember member)
{
var mapped = base.MapFromMember(member);
mapped.LockoutEnabled = member.GetValue<int>("lockoutEnabled") == 1;
return mapped;
}
} Replace the user manager
|
Hi,
I've check this code/link
but I cannot use this
if (!await UserManager.IsEmailConfirmedAsync(user.Id))
gives me this error
The method or operation is not implemented.
What can I do?
Best regards,
Pedro
The text was updated successfully, but these errors were encountered: