public async Task <IActionResult> OnGetAsync(string email, string returnUrl) { var user = await _userManager.FindByEmailAsync(email); var factors = await _multiFactorUserStore.GetFactorsAsync(user, CancellationToken.None); ReturnUrl = returnUrl; var inputFactors = (from factor in factors let c = new InputMultiFactorStepTwoModel.ApplicationFactorHandle { Challenge = factor.Challenge } select c).ToList(); Input = new InputMultiFactorStepTwoModel() { Email = email, Factors = inputFactors }; return(Page()); }
public async Task <IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var userName = await _userManager.GetUserNameAsync(user); Username = userName; Input = new InputModel(); Factors = await _multiFactorUserStore.GetFactorsAsync(user, CancellationToken.None); return(Page()); }
public async Task Create_User_many_Factor() { var testUser = CreateTestUser(); var createUserResult = await _userStore.CreateAsync(testUser, CancellationToken.None); createUserResult.ShouldNotBeNull(); createUserResult.Succeeded.ShouldBeTrue(); int nCount = 10; for (int i = 0; i < nCount; ++i) { var challengeFactor = CreateTestFactor(); var identityResult = await _multiFactorUserStore.AddToFactorAsync( testUser, challengeFactor, CancellationToken.None); identityResult.ShouldNotBeNull(); identityResult.Succeeded.ShouldBeTrue(); var findResult = await _multiFactorUserStore.FindByIdAsync(challengeFactor.FactorId, CancellationToken.None); findResult.ShouldNotBeNull(); findResult.FactorId.ShouldBe(challengeFactor.FactorId); } var factors = await _multiFactorUserStore.GetFactorsAsync(testUser, CancellationToken.None); factors.ShouldNotBeNull(); factors.Count.ShouldBe(nCount); foreach (var factor in factors) { factor.ShouldNotBeNull(); factor.Challenge.ShouldNotBeNull(); factor.ChallengeResponseHash.ShouldNotBeNull(); factor.FactorId.ShouldNotBeNull(); } }