protected void Page_Load(object sender, EventArgs e) { try { string currentPage = System.IO.Path.GetFileName(Request.Url.AbsolutePath); if (currentPage == "Verify2FA") { if (Session["OptimflexPortalUserData"] != null) { CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); if (varUserData.USR_ISENABLED_2FA == 0) { Response.Redirect("~/"); } else { if (varUserData.USR_ISVERIFIED_2FA == 1) { Response.Redirect("~/"); } } } else { Response.Redirect("~/Login"); } } } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { try { CMain mainClass = new CMain(); mainClass.PageInit(); CSession mySession = new CSession(); var myUserData = mySession.getCurrentUserData(); spanUserLastname.InnerHtml = myUserData.USR_LASTNAME; spanUserFirstname.InnerHtml = myUserData.USR_FIRSTNAME; inputProfileData.Value = "{\"profile_selectUserType\": \"" + myUserData.USR_TYPE + "\", \"profile_inputUserMiddleName\": \"" + myUserData.USR_FAMILYNAME + "\", \"profile_inputUserLastName\": \"" + myUserData.USR_LASTNAME + "\", \"profile_inputUserFirstName\": \"" + myUserData.USR_FIRSTNAME + "\", \"profile_selectUserGender\": \"" + myUserData.USR_GENDER + "\", \"profile_inputUserEmail\": \"" + myUserData.USR_USERNAME + "\", \"profile_inputUserTel1\": \"" + myUserData.USR_TEL1 + "\", \"profile_inputUserTel2\": \"" + myUserData.USR_TEL2 + "\", \"profile_inputUserBirthday\": \"" + myUserData.USR_BIRTHDATE + "\", \"profile_check2FAuth\":\"" + myUserData.USR_ISENABLED_2FA + "\"}"; } catch (Exception ex) { throw ex; } }
public string Check2FAAuth(string pCode) { CJsonResponse jsonResClass = new CJsonResponse(); try { TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); bool isCorrectPIN = tfa.ValidateTwoFactorPIN(varUserData.AUTH_2FA_SECRET_KEY, pCode); if (isCorrectPIN) { varUserData.USR_ISVERIFIED_2FA = 1; mySession.setUserData(varUserData); return(jsonResClass.JsonResponse(intJsonStatusSuccess, "Амжилттай", null)); } return(jsonResClass.JsonResponse(intJsonStatusFailed, "Код буруу байна", null)); } catch (Exception ex) { return(jsonResClass.JsonResponse(intJsonStatusFailed, "Системд алдаа гарлаа", null)); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["OptimflexPortalUserData"] != null) { CSession mySession = new CSession(); var varUserData = mySession.getCurrentUserData(); if (varUserData.USR_ISENABLED_2FA == 0) { Response.Redirect("~/"); } else { if (varUserData.USR_ISVERIFIED_2FA == 1) { Response.Redirect("~/"); } else { try { TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); var setupInfo = tfa.GenerateSetupCode(varUserData.AUTH_2FA_ISSUER_NAME, varUserData.AUTH_2FA_ISSUER_NOTE, varUserData.AUTH_2FA_SECRET_KEY, varUserData.AUTH_2FA_QRCODE_WIDTH, varUserData.AUTH_2FA_QRCODE_HEIGHT); //the width and height of the Qr Code in pixels verify2fa_imgQRCode.Src = setupInfo.QrCodeSetupImageUrl; verify2fa_spanEntryCode.InnerHtml = setupInfo.ManualEntryKey; } catch (Exception ex) { throw ex; } } } } else { Response.Redirect("~/Login"); } }