Skip to content

Instantly share code, notes, and snippets.

@AbubakarSiddiq
Created January 4, 2017 18:39
Show Gist options
  • Save AbubakarSiddiq/ce34b8852138d94627ee1f5b0bc86ac3 to your computer and use it in GitHub Desktop.
Save AbubakarSiddiq/ce34b8852138d94627ee1f5b0bc86ac3 to your computer and use it in GitHub Desktop.
[HttpPost]
public ActionResult Login(LoginModel login)
{
string message = "";
bool status = false;
//check UserName and password form our database here
if (login.UserName == "Admin" && login.Password == "12345") // Admin as user name and 12345 as Password
{
status = true;
message = "Two Factor Authentication Verification";
Session["UserName"] = login.UserName;
//Two Factor Authentication Setup
TwoFactorAuthenticator TwoFacAuth = new TwoFactorAuthenticator();
string UserUniqueKey = (login.UserName + key);
Session["UserUniqueKey"] = UserUniqueKey;
var setupInfo = TwoFacAuth.GenerateSetupCode("Dot Net Detail", login.UserName, UserUniqueKey, 300, 300);
ViewBag.BarcodeImageUrl = setupInfo.QrCodeSetupImageUrl;
ViewBag.SetupCode = setupInfo.ManualEntryKey;
}
else
{
message = "Please Enter the Valid Credential!";
}
ViewBag.Message = message;
ViewBag.Status = status;
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment