using System; using System.Threading.Tasks; using InventoryTraker.Web.Core; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin.Security.DataProtection; namespace InventoryTraker.Web.Identity { public class ApplicationRoleManager : RoleManager { public const string AdminRoleName = "Admin"; public ApplicationRoleManager(IRoleStore store) : base(store) { } } public class ApplicationUserManager : UserManager { public ApplicationUserManager(IUserStore store, IDataProtectionProvider dataProtectionProvider) : base(store) { UserValidator = new UserValidator(this) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = true }; if (dataProtectionProvider != null) { var dataProtector = dataProtectionProvider.Create("Protector"); UserTokenProvider = new DataProtectorTokenProvider(dataProtector) { TokenLifespan = TimeSpan.FromHours(1), }; } } public async Task ChangePasswordAsync(User user, string newPassword) { var resetToken = await GeneratePasswordResetTokenAsync(user.Id); return await ResetPasswordAsync(user.Id, resetToken, newPassword); } } }