本文整理汇总了C#中VerifyCodeViewModel类的典型用法代码示例。如果您正苦于以下问题:C# VerifyCodeViewModel类的具体用法?C# VerifyCodeViewModel怎么用?C# VerifyCodeViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerifyCodeViewModel类属于命名空间,在下文中一共展示了VerifyCodeViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
// The following code protects for brute force attacks against the two factor codes.
// If a user enters incorrect codes for a specified amount of time then the user account
// will be locked out for a specified amount of time.
// You can configure the account lockout settings in IdentityConfig
var result = await this.SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return this.RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return this.View("Lockout");
case SignInStatus.Failure:
default:
this.ModelState.AddModelError("", "Invalid code.");
return this.View(model);
}
}
示例2: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// Приведенный ниже код защищает от атак методом подбора, направленных на двухфакторные коды.
// Если пользователь введет неправильные коды за указанное время, его учетная запись
// будет заблокирована на заданный период.
// Параметры блокирования учетных записей можно настроить в IdentityConfig
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Неправильный код.");
return View(model);
}
}
示例3: VerifyCodePostRedirectsToReturnUrlWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsLocalUrl
public async Task VerifyCodePostRedirectsToReturnUrlWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsLocalUrl()
{
var model = new VerifyCodeViewModel { ReturnUrl = "returnUrl" };
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Success);
var urlHelper = new Mock<IUrlHelper>();
urlHelper.Setup(x => x.IsLocalUrl(model.ReturnUrl)).Returns(true);
var sut = new AdminController(null, signInManager.Object, null, null, null) { Url = urlHelper.Object };
var result = await sut.VerifyCode(model) as RedirectResult;
Assert.Equal(result.Url, model.ReturnUrl);
}
示例4: VerifyCodePostInvokesTwoFactorSignInAsyncWithCorrectParameters
public async Task VerifyCodePostInvokesTwoFactorSignInAsyncWithCorrectParameters()
{
var model = new VerifyCodeViewModel
{
Provider = "provider",
Code = "code",
RememberBrowser = true,
RememberMe = true
};
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(new Microsoft.AspNetCore.Identity.SignInResult());
var sut = new AdminController(null, signInManager.Object, null, null, null);
await sut.VerifyCode(model);
signInManager.Verify(x => x.TwoFactorSignInAsync(model.Provider, model.Code, model.RememberMe, model.RememberBrowser));
}
示例5: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// El código siguiente protege de los ataques por fuerza bruta a los códigos de dos factores.
// Si un usuario introduce códigos incorrectos durante un intervalo especificado de tiempo, la cuenta del usuario
// se bloqueará durante un período de tiempo especificado.
// Puede configurar el bloqueo de la cuenta en IdentityConfig
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Código no válido.");
return View(model);
}
}
示例6: VerifyRegistrationCode
public async Task<ActionResult> VerifyRegistrationCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await UserManager.FindByEmailAsync(model.Email);
if (user == null)
{
ModelState.AddModelError("", ApplicationMessages.UserNotFoundForGivenEmail);
return View(model);
}
if (user.PhoneNumberConfirmed)
{
ModelState.AddModelError("", ApplicationMessages.UserAlreadyConfirmed);
return View(model);
}
var result = await UserManager.ConfirmPhoneNumberAsync(user.Id, model.Code);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
await UserManager.SendSmsAsync(user.Id, ApplicationMessages.SignupComplete);
return RedirectToAction("Status");
}
else
{
AddErrors(result);
return View(model);
}
}
示例7: VerifyCode
public async Task<ActionResult> VerifyCode(string provider, string returnUrl, bool rememberMe)
{
// Require that the user has already logged in via username/password or external login
if (!await this.SignInManager.HasBeenVerifiedAsync())
{
return this.View("Error");
}
var model = new VerifyCodeViewModel
{
Provider = provider,
ReturnUrl = returnUrl,
RememberMe = rememberMe
};
return this.View(model);
}
示例8: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var result = await this.SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, false, model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return this.RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return this.View("Lockout");
// ReSharper disable once RedundantCaseLabel
case SignInStatus.Failure:
default:
this.ModelState.AddModelError(string.Empty, Common.InvalidCode);
return this.View(model);
}
}
示例9: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// 以下代码可以防范双重身份验证代码遭到暴力破解攻击。
// 如果用户输入错误代码的次数达到指定的次数,则会将
// 该用户帐户锁定指定的时间。
// 可以在 IdentityConfig 中配置帐户锁定设置
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "代码无效。");
return View(model);
}
}
示例10: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// Le code suivant protège des attaques par force brute contre les codes à 2 facteurs.
// Si un utilisateur entre des codes incorrects pendant un certain intervalle, le compte de cet utilisateur
// est alors verrouillé pendant une durée spécifiée.
// Vous pouvez configurer les paramètres de verrouillage du compte dans IdentityConfig
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Code non valide.");
return View(model);
}
}
示例11: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// Der folgende Code schützt vor Brute-Force-Angriffen der zweistufigen Codes.
// Wenn ein Benutzer in einem angegebenen Zeitraum falsche Codes eingibt, wird das Benutzerkonto
// für einen bestimmten Zeitraum gesperrt.
// Sie können die Einstellungen für Kontosperren in "IdentityConfig" konfigurieren.
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Ungültiger Code.");
return View(model);
}
}
示例12: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// 다음 코드는 2단계 코드를 통해 무차별 암호 대입 공격(brute force attack)으로부터 보호합니다.
// 사용자가 지정된 시간 동안 잘못된 코드를 입력하면
// 지정된 시간 동안 사용자 계정이 잠깁니다.
// IdentityConfig에서 계정 잠금 설정을 구성할 수 있습니다.
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "잘못된 코드입니다.");
return View(model);
}
}
示例13: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// 次のコードは、2 要素コードに対するブルート フォース攻撃を防ぎます。
// ユーザーが誤ったコードを入力した回数が指定の回数に達すると、ユーザー アカウントは
// 指定の時間が経過するまでロックアウトされます。
// アカウント ロックアウトの設定は IdentityConfig の中で構成できます。
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "無効なコード。");
return View(model);
}
}
示例14: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
// 下列程式碼保護兩個因素碼不受暴力密碼破解攻擊。
// 如果使用者輸入不正確的代碼來表示一段指定的時間,則使用者帳戶
// 會有一段指定的時間遭到鎖定。
// 您可以在 IdentityConfig 中設定帳戶鎖定設定
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "代碼無效。");
return View(model);
}
}
示例15: VerifyCode
public async Task<ActionResult> VerifyCode(VerifyCodeViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: false, rememberBrowser: model.RememberBrowser);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Invalid code.");
return View(model);
}
}