SMS Services by twilio and Ultra Message
for reference
https://apps.quantumbso.com/ocnawcdev/frmLogin.aspx
<html>
<head></head>
<title></title>
<body>
<h1>SMS Services by twilio and Ultra Message</h1>
<h2>Code by Anil Dwivedi</h2>
<p>
First we login in Twilio account and get AccountSid and AuthToken form Twilio Account then
on button click we work on
here is my frmLogin.aspx page which is as per client requirement .
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frmLogin.aspx.vb" Async="true" EnableEventValidation="false" Inherits="QflxDev.WorkFlow.frmLogin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title id="Title"></title>
<link rel="stylesheet" id="CSSLink" />
<%=strCommonFunctionPath%>
<script type="text/javascript" src="Supports/Scripts/CommonFunction.js"></script>
<%--<script type="text/javascript" src="Supports/Scripts/jquery-1.7.2.min.js"></script> --%>
<%--<script type="text/javascript" src="Supports/Scripts/JQuery-3.6.0.min.js"></script>--%>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="/resources/demos/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
<script type="text/javascript">
var Project = '<%=ProjectName%>';
var UserSessionID = '<%=Session("USERSESSION_ID")%>';
var availHeight = 0;
var availWidth = 0;
function SetWidth(width, height) {
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
var _mainWidth = parseInt((1024 / parseInt(width)) * 100);
if (is_ie == 1) {
// document.getElementById('loginTbl').style.marginLeft = '20%';
}
else {
document.getElementById('tblParent').style.width = "100%";
document.getElementById('tdLeft').style.width = ((100 - _mainWidth) / 2).toString() + '%';
document.getElementById('tdMiddle').style.width = _mainWidth.toString() + '%';
document.getElementById('tdRight').style.width = ((100 - _mainWidth) / 2).toString() + '%';
//document.getElementById('loginTbl').style.marginLeft = ((parseInt(width) / 2) - 428).toString() + 'px';
document.getElementById('loginTbl').style.marginLeft = "375px"; //((parseInt(width) / 2) - 150).toString() + 'px';
}
}
function LoadMe() {
document.getElementById('<%=txtUSER_ID.ClientID%>');
document.getElementById('<%=txtPassword.ClientID%>');
//document.all.tdImgTop.style.backgroundImage = 'url(Supports/Images/topbanner.gif)';
//document.all.tdSplash.style.backgroundImage = 'url(Supports/Images/LoginImage.gif)';
//document.all.CSSLink.href = "Supports/CSS/StyleWGrid.css";
deleteAllCookies();
top.window.moveTo(0, 0);
if (document.all) {
SetWidth(window.screen.width, window.screen.height);
top.window.resizeTo(window.screen.width, window.screen.height);
}
else if (document.layers || document.getElementById) {
SetWidth(top.window.outerWidth, top.window.outerHeight);
if (top.window.outerHeight < availHeight || top.window.outerWidth < availWidth) {
top.window.outerHeight = availHeight;
top.window.outerWidth = availWidth;
}
}
if (document.getElementById('txtShowLogin').value == 1) {
var y = document.getElementById("InputPage");
y.style.display = "block";
}
else {
closemodal();
}
updateTimer();
document.getElementById('hdnResolution').value = screen.width;
if (document.getElementById('hdnRegistrationflg').value == 0) {
var arrHeader = new Array('Registration Code')
sFeatures = 'dialogWidth:600px;status= no;resizable= no;dialogHeight:300px;scrollable=no;'
var strReturnval = null
var str_result;
strReturnval = ""
var url = "Forms/LicenseKey/frm_QLicense_Key_Validation.aspx";
strReturnval = window.showModalDialog(url, arrHeader, sFeatures);
if (strReturnval == 'undefined' || strReturnval == undefined) {
return true;
}
if (strReturnval != 'undefined' || strReturnval != undefined) {
if (strReturnval == 'OnCancel') {
var form = document.getElementById("Form2")
form.submit();
}
str_result = strReturnval.split("###");
document.getElementById('hdnRegistrationKey').value = str_result[0];
document.getElementById('hdnServerKey').value = str_result[1];
}
return true;
}
document.getElementById('<%=txtUSER_ID.ClientID%>');
document.getElementById('txtVerification').focus();
return false;
}
var countDownDate = new Date().getTime() + (2.5 * 60 * 1000);
var timerInterval = setInterval(updateTimer, 1000); // Start the timer
function updateTimer() {
var now = new Date().getTime();
var distance = countDownDate - now;
if (distance < 0) {
clearInterval(timerInterval);
document.getElementById("timer").innerHTML = "Sorry the time is Up… Please request for a New OTP.";
/* alert("Please request to Resend Otp");*/
document.getElementById("resend").style.display = "inline-block"; // show the Resend OTP button
document.getElementById("btnFetchOtp").style.display = "none"; // show the Resend OTP button
document.getElementById("LoginSuccessfull").style.display = "none"; // show the Resend OTP button
} else {
var minutes = Math.floor(distance / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
var timerString = "";
if (minutes > 0) {
timerString += minutes + " minute" + (minutes > 1 ? "s" : "") + " ";
}
if (seconds > 0) {
timerString += (seconds < 10 && minutes > 0 ? "0" : "") + seconds + " second" + (seconds > 1 ? "s" : "");
}
document.getElementById("timer").innerHTML = timerString + " remaining";
}
}
function resendOTP() {
// Code to resend the OTP goes here
alert("OTP resent successfully!"); // Display a message to the user
document.getElementById("resend").style.display = "none"; // Hide the "Resend OTP" button again
countDownDate = new Date().getTime() + (2.5 * 60 * 1000); // Reset the countdown time to 2 minutes
clearInterval(timerInterval); // Stop the previous timer
timerInterval = setInterval(updateTimer, 1000); // Start a new timer
}
function OpenPwdEntry() {
var arrHeader = new Array('Search - Company')
sFeatures = 'dialogWidth:565px;status= no;resizable= no;dialogHeight:141px;scrollable=no;'
var strReturn = null
var url = "frmForgotPass.aspx";
window.showModalDialog(url, arrHeader, sFeatures);
}
//function verificationotp() {
// var arrHeader = new Array('Search - Company')
// sFeatures = 'dialogWidth:865px;status= no;resizable= yes;dialogHeight:241px;scrollable=no;'
// var strReturn = null
// var url = "VerificationOtp.aspx";
// window.showModalDialog(url, arrHeader, sFeatures);
//}
function RegisterNewKey() {
var arrHeader = new Array('Registration Code')
sFeatures = 'dialogWidth:600px;status= no;resizable= no;dialogHeight:300px;scrollable=no;'
var strReturnval = null
var str_result;
strReturnval = ""
var url = "Forms/LicenseKey/frm_QLicense_Key_Validation.aspx";
strReturnval = window.showModalDialog(url, arrHeader, sFeatures);
if (strReturnval == 'undefined' || strReturnval == undefined) {
return true;
}
if (strReturnval != 'undefined' || strReturnval != undefined) {
if (strReturnval == 'OnCancel') {
var form = document.getElementById("Form2")
form.submit();
}
str_result = strReturnval.split("###");
document.getElementById('hdnRegistrationKey').value = str_result[0];
document.getElementById('hdnServerKey').value = str_result[1];
}
return true;
}
function VerifyOtpKey() {
var arrHeader = new Array('Verification Code');
sFeatures = 'dialogWidth:600px;status= no;resizable= no;dialogHeight:300px;scrollable=no;';
var strReturnval = null;
var str_result;
strReturnval = "";
var url = "frmLoginOtpWhatsApp.aspx";
strReturnval = window.showModalDialog(url, arrHeader, sFeatures);
if (strReturnval == 'undefined' || strReturnval == undefined) {
return true;
}
if (strReturnval != 'undefined' || strReturnval != undefined) {
if (strReturnval == 'OnCancel') {
var form = document.getElementById("Form2")
if (confirm("Are you sure, want to refresh?")) {
location.reload();
}
}
str_result = strReturnval.split("###");
document.getElementById('hdnRegistrationKey').value = str_result[0];
document.getElementById('hdnServerKey').value = str_result[1];
}
return true;
}
// $(document).ready(function () {
// document.getElementById('<%=txtUSER_ID.ClientID%>').focus();
// if (Project == 'QILS') {
// document.all.tdMiddle.style.backgroundImage = 'url(Supports/Images/NewCSSImages/qils-newlogo.png)';
// document.title = "Welcome to Q-iLS...";
// }
// else {
// document.all.tdMiddle.style.backgroundImage = 'url(Supports/Images/NewCSSImages/qflx-newlogo.jpg)';
// document.title = "Welcome to Q-FLX...";
// }
// var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
// if (is_ie == 1) {
// var watermarkUID = 'USER ID';
// var watermarkUPWD = 'PASSWORD';
// document.getElementById('<%=txtUSER_ID.ClientID%>').focus();
// $('#<%=txtUSER_ID.ClientID %>').val(watermarkUID).addClass('watermark');
// //if blur and no value inside, set watermark text and class again.
// $('#<%=txtUSER_ID.ClientID %>').blur(function () {
// if ($(this).val().length == 0) {
// $(this).val(watermarkUID).addClass('watermark');
// }
// $('#<%=txtPassword.ClientID %>').val('').removeClass('watermark');
// }); //init, set watermark text and class for USER ID
// //if focus and text is watermrk, set it to empty and remove the watermark class
// $('#<%=txtUSER_ID.ClientID %>').keypress(function () {
// if ($(this).val() == watermarkUID) {
// $(this).val('').removeClass('watermark');
// }
// $('#<%=txtPassword.ClientID %>').val('').removeClass('watermark');
// });
// $('#<%=txtUSER_ID.ClientID %>').click(function () {
// $(this).val('').removeClass('watermark');
// });
// //init, set watermark text and class for USER Password
// $('#<%=txtPassword.ClientID %>').val(watermarkUID).addClass('watermark');
// //if blur and no value inside, set watermark text and class again.
// $('#<%=txtPassword.ClientID %>').blur(function () {
// if ($(this).val().length == 0) {
// $(this).val(watermarkUPWD).addClass('watermark');
// }
// });
// //if focus and text is watermrk, set it to empty and remove the watermark class
// $('#<%=txtPassword.ClientID %>').keypress(function () {
// if ($(this).val().toUpperCase() == watermarkUPWD.toUpperCase()) {
// $(this).val('').removeClass('watermark');
// }
// });
// //if focus and text is watermrk, set it to empty and remove the watermark class
// $('#<%=txtPassword.ClientID %>').click(function () {
// $(this).val('').removeClass('watermark');
// });
// }
// $('#<%=cmdLogin.ClientID %>').click(function () {
// return getIPSessPreUserID();
// });
// });
function MyFunction() {
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
if (is_ie == 1) {
var watermarkUID = 'USER ID';
var watermarkUPWD = 'PASSWORD';
document.getElementById('<%=txtUSER_ID.ClientID%>').focus();
$('#<%=txtUSER_ID.ClientID %>').val(watermarkUID).addClass('watermark');
//if blur and no value inside, set watermark text and class again.
$('#<%=txtUSER_ID.ClientID %>').blur(function () {
if ($(this).val().length == 0) {
$(this).val(watermarkUID).addClass('watermark');
}
$('#<%=txtPassword.ClientID %>').val('').removeClass('watermark');
}); //init, set watermark text and class for USER ID
//if focus and text is watermrk, set it to empty and remove the watermark class
$('#<%=txtUSER_ID.ClientID %>').keypress(function () {
if ($(this).val() == watermarkUID) {
$(this).val('').removeClass('watermark');
}
$('#<%=txtPassword.ClientID %>').val('').removeClass('watermark');
});
$('#<%=txtUSER_ID.ClientID %>').click(function () {
$(this).val('').removeClass('watermark');
});
//init, set watermark text and class for USER Password
$('#<%=txtPassword.ClientID %>').val(watermarkUID).addClass('watermark');
//if blur and no value inside, set watermark text and class again.
$('#<%=txtPassword.ClientID %>').blur(function () {
if ($(this).val().length == 0) {
$(this).val(watermarkUPWD).addClass('watermark');
}
});
//if focus and text is watermrk, set it to empty and remove the watermark class
$('#<%=txtPassword.ClientID %>').keypress(function () {
if ($(this).val().toUpperCase() == watermarkUPWD.toUpperCase()) {
$(this).val('').removeClass('watermark');
}
});
//if focus and text is watermrk, set it to empty and remove the watermark class
$('#<%=txtPassword.ClientID %>').click(function () {
$(this).val('').removeClass('watermark');
});
}
$('#<%=cmdLogin.ClientID %>').click(function () {
return getIPSessPreUserID();
});
}
function ChkMandatory() {
alert("You entered wrong OTP three times. Please try again.")
if (document.getElementById('txtUserID').value == "") {
alert("Please Enter OTP.");
document.getElementById('txtUserID').focus();
return false;
}
}
function showLogin() {
var y = document.getElementById("InputPage");
y.style.display = "block";
document.getElementById("lblStatus").value = '';
document.getElementById("txtUSER_ID").value = '';
document.getElementById("txtPassword").value = '';
// var watermarkUID = 'USER ID';
// var watermarkUPWD = 'PASSWORD';
// $('#<%=txtUSER_ID.ClientID %>').val(watermarkUID).addClass('watermark');
// $('#<%=txtPassword.ClientID %>').val(watermarkUPWD).addClass('watermark');
this.MyFunction();
// var x = document.getElementById('login_box');
// x.style.display = "none";
}
function closemodal() {
var y = document.getElementById("InputPage");
y.style.display = "none";
}
function getIPSessPreUserID() {
if ('<%=IsMultiSessionEnabled%>' == true) {
var UserID = document.getElementById('txtUSER_ID').value;
var PssWord = document.getElementById('txtPassword').value;
if (UserID == '' || PssWord == '') {
return true;
}
var sql = "SELECT U.USER_ID FROM QCOR_UA_LOGIN_ACTIVITY Q, USER_MST_TBL U ";
sql += " WHERE Q.USER_MST_FK = U.USER_MST_PK "
sql += " AND Q.LOGIN_STATUS = 1 ";
sql += " AND UPPER(Q.SESSION_ID)=UPPER('" + UserSessionID.toUpperCase() + "')";
sql += " AND UPPER(Q.LOGIN_CLIENT_IP)=UPPER('" + document.getElementById('hdnIPAddress').value.toUpperCase() + "')";
fn_Freight_Element('hdnIPSessPrUsr', sql);
if (document.getElementById('hdnIPSessPrUsr').value == '') {
return true;
}
else {
if (document.getElementById('hdnIPSessPrUsr').value.toUpperCase() != UserID.toUpperCase()) {
alert(document.getElementById('hdnIPSessPrUsr').value + ' is already active in this PC, Multiple Logins are restricted in the same PC.');
return false;
}
}
var y = document.getElementById("InputPage");
y.style.display = "block";
}
else {
var UserID = document.getElementById('txtUSER_ID').value;
var PssWord = document.getElementById('txtPassword').value;
if (UserID == '') {
alert('Enter User ID');
var y = document.getElementById("InputPage");
y.style.display = "block";
return false;
}
if (PssWord == '') {
alert('Enter Password');
var y = document.getElementById("InputPage");
y.style.display = "block";
return false;
}
// var statusTextval = document.getElementById("lblStatus").Text;
// if (statusTextval == 'undefined' || statusTextval == undefined) {
// var y = document.getElementById("InputPage");
// y.style.display = "block";
// return false;
// }
return true;
}
}
function fn_Freight_Element(ControlId, sqlQury) {
var reqURL = "Forms/24CommonForm/frmEnhanceSearch.aspx?q="
var url = reqURL + 'E~';
url = url + sqlQury + '~' + 'Active=' + Math.random();
url = url + '&Search=Common~AjaxFunction';
xmlHttp = GetXmlHttpObject(stateChangeHandler);
xmlHttp_Get_False(xmlHttp, url);
function stateChangeHandler() {
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
var str = xmlHttp.responseText;
var result = str;
if (result == '') {
}
else {
document.getElementById('hdnIPSessPrUsr').value = result;
}
}
}
}
function deleteAllCookies() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
}
function GetPref() {
var sql = "SELECT FN_USER_OTPPREF('" + document.getElementById('txtUSER_ID').value + "') FROM DUAL";
fn_Freight_Element('hdnIPSessPrUsr', sql);
if (document.getElementById('hdnIPSessPrUsr').value == '3') {
document.getElementById('RadioButton2').checked = true;
document.getElementById('RadioButton1').checked = false;
document.getElementById('RadioEmail').checked = false;
}
else if (document.getElementById('hdnIPSessPrUsr').value == '2') {
document.getElementById('RadioButton2').checked = false;
document.getElementById('RadioButton1').checked = true;
document.getElementById('RadioEmail').checked = false;
}
else {
document.getElementById('RadioButton2').checked = false;
document.getElementById('RadioButton1').checked = false;
document.getElementById('RadioEmail').checked = true;
}
document.getElementById('txtUSER_ID').removeAttribute('onblur'); // remove the onblur attribute
return false;
}
document.getElementById('txtUSER_ID').addEventListener('blur', function () {
GetPref();
});
function GetTab() {
document.getElementById('txtVerification').focus();
}
//function validation_Id(event) {
// var key = event.keyCode || event.which;
// var keychar = String.fromCharCode(key);
// var pattern = /^[0-9]/;
// if (key == 8 || key == 9 || key == 13 || key == 27 || key == 46 ||
// (key >= 35 && key <= 40) || pattern.test(keychar)) {
// // Allow backspace, tab, enter, escape, delete, arrow keys, and numeric input
// return true;
// } else if (keychar.match(/[!@#$%^&*()]/)) {
// // Block specific special characters and display an error message
// /* alert("Please enter only numbers.");*/
// return false;
// } else {
// // Block other input and display an error message
// /* alert("Please enter only numbers.");*/
// return false;
// }
//}
function validation_Id(event) {
var key = event.keyCode || event.which;
var keychar = String.fromCharCode(key);
var pattern = /^[0-9]+$/;
if ( key == 8 || key == 9 || key == 13 || key == 27 || key == 46 ||
(key >= 35 && key <= 40) || pattern.test(keychar) && !event.shiftKey) {
// Allow backspace, tab, enter, escape, delete, arrow keys, and numeric input
return true;
} else {
// Block other input and display an error message
if (keychar === "#" || keychar === "@" || keychar === "*" || keychar === "!" || keychar === "$" || keychar === "%" || keychar === "^" || keychar === "&" || keychar === "(" || keychar === ")") {
/* 'alert("Special characters #, @, !, $, %, ^, &, *, (, and ) are not allowed.");*/
return false;
} else {
/*'alert("Please enter only numbers.");*/
}
return false;
}
}
//function validation_Id(event) {
// var key = event.keyCode || event.which;
// var keychar = String.fromCharCode(key);
// var pattern = /^[0-9]+$/;
// if (event.shiftKey || key == 8 || key == 9 || key == 13 || key == 27 || key == 46 ||
// (key >= 35 && key <= 40) || pattern.test(keychar)) {
// // Allow backspace, tab, enter, escape, delete, arrow keys, and numeric input
// return true;
// } else {
// // Block other input and display an error message
// if (keychar === "#" || keychar === "@" || keychar === "*" || keychar === "!" || keychar === "$" || keychar === "%" || keychar === "^" || keychar === "&" || keychar === "(" || keychar === ")") {
// /* 'alert("Special characters #, @, !, $, %, ^, &, *, (, and ) are not allowed.");*/
// return false;
// } else {
// /*'alert("Please enter only numbers.");*/
// }
// return false;
// }
// //var key = event.keyCode || event.which;
// //var keychar = String.fromCharCode(key);
// //var pattern = /^[0-9]+$/;
// //if ( (key >= 97 && key <= 122) || key === 8 || pattern.test(keychar)) {
// // return true;
// //} else {
// // if (keychar === "#")
// // return false;
// //}
//}
</script>
<style type="text/css">
.logintext {
font-family: 'Helvetica', 'Times New Roman';
font-weight: lighter;
font-size: 16px;
color: #C4C4C4;
background-color: #464447;
/*background-color:#f6f6f6f;*/
height: 40px;
width: 100%;
border-style: none;
-moz-border-radius: 0 0 10px 10px;
-webkit-border-radius: 0 0 10px 10px;
}
.loginbutton {
font-family: 'Helvetica', 'Times New Roman';
font-weight: bold;
font-size: 18px;
color: #bbb;
background-color: #252326;
height: 35px;
width: 130px;
border-style: none;
cursor: pointer;
}
#loginTbl tr {
height: 0px;
vertical-align: middle;
}
.linklabel {
/*color: #686869;*/
color:#fff;
text-decoration: none;
font-size: 11pt;
letter-spacing: 1px;
font-weight: bold;
font-family: 'Helvetica', 'Times New Roman';
}
.linklabel:hover{
text-decoration:none;
color:#fff;
}
input.watermark {
color: #999;
}
input {
padding: 8px;
text-indent: 5px;
/* width: 200px;*/
font-size: 12px;
}
.modal-input {
display: none;
}
.submit {
width: 433px;
height: 70px;
/*background: #6CB0EE 0% 0% no-repeat padding-box;*/
/*background:#00B9F2!important;*/
background:#6cb0ef;
/*border: 1px solid #707070;*/
border:1px solid #6cb0ef!important;
font-family: Segoe UI;
font-size: 25px;
margin-top: 40px;
cursor: pointer;
/*color:#fff!important;*/
color:#030004;
}
.login_box {
/*background: #070707;*/
width: 600px;
height: 281px;
text-align: center;
color: #ffffff;
position: absolute;
top: 30%;
left: 30%;
webkit-transform: translate(-50%, -50%)!important;
background:#070707 important;
box-shadow:4px 4px 16px #00000029!important;
border-radius:4px!important;
}
.login_box1 {
background: #323232!important;
height: 420px;
width:400px;
text-align: center;
color: #fff;
position: absolute;
top: 18%;
left: 37.5%;
padding: 10px;
bottom: 15%!important;
-webkit-transform: translate(-10%, -10%);
/*overflow:hidden;*/
}
.welcome_h2 {
text-align: center;
letter-spacing: 0px;
/*color: #FEFEFE;*/
color:#fff;
font-weight:bold;
/*margin-top: 40px;*/
margin-top:20px;
font-size: 30px;
font-family: Segoe UI !important;
}
.close_btn {
position: absolute;
top: -13px;
right: -13px;
cursor: pointer;
border: none;
font-size: 12px;
width: 25px;
height: 25px;
z-index:99!important;
}
.login_btn {
width: 100%;
border: 1px solid #6CB0EE;
/*background:#00B9F2;*/
background: #6CB0EE;
cursor: pointer;
outline: 0;
color: #030004!important;
margin-top: 0px;
height: 40px;
font-size: 16px;
font-weight:300;
margin-top: 10px;
margin-bottom:10px;
}
.login_sidenav {
position: absolute;
left: 0px;
z-index: 99;
top: 0px;
width: 78px;
text-align: center;
background: #6CB0EE;
height:100%;
}
.logo_img {
background: #009fe3 0% 0% no-repeat padding-box;
height: 48px;
width: 60px;
/*margin-top: 15px;*/
margin-top:10px;
}
.el_img {
position: absolute;
bottom: 15px;
left: 15px;
width: 50px;
height: 140px;
}
</style>
</head>
<body class="Body" style="margin: 0 0 0 0; overflow: hidden; text-align: center; background-color: #292929;"
onload="javascript:LoadMe();">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div class="login_sidenav">
<br />
<img alt="" class="logo_img" src="Supports/Images/NewImages/client.jpg" />
<img alt="" class="el_img" src="Supports/Images/NewImages/header-new-logo.png" />
<br />
<br />
<br />
<br />
<br />
</div>
<div class="login_box" id="login_box">
<table border="0" bordercolor="red">
<tr>
<td align="center">
<h2 class="welcome_h2">Welcome Back</h2>
</td>
</tr>
<tr>
<td align="center">
<button class="submit" onclick="showLogin()">Login</button></td>
</tr>
</table>
<%-- <h2 class="welcome_h2" >Welcome Back</h2>--%>
</div>
<div class="login_box1" style="display: none" id="InputPage">
<%-- <button class="close_btn" onclick="closemodal()">
<img alt="" src="Supports/Images/close-circle.png" width="18px" />
</button>--%>
<img class="close_btn" onclick="closemodal()" alt="" src="Supports/Images/close-circle.png" width="18px" />
<form id="frmLogin" method="post" runat="server">
<table id="tblParent" border="0" bordercolor="red">
<tr>
<td id="tdLeft"></td>
<td id="">
<table id="loginTbl" style="text-align: center; width: 300px; margin-top: 0px; position: relative;">
<br />
<asp:Label ID="lblmsg" runat="server" ForeColor="Black" Font-Bold="True"></asp:Label><input
id="hdnUserPk" style="width: 16px; height: 22px" type="hidden" size="1" name="hdnUserPk"
runat="server" />
<tr>
<td style="text-align: center;">
<asp:TextBox ID="txtUSER_ID" TabIndex="1" CssClass="logintext" placeholder="User ID" runat="server" Columns="15"
MaxLength="20" onblur="GetPref();"></asp:TextBox>
</td>
</tr>
<tr style="height: 10px;">
<td width="10px" align="left"></td>
</tr>
<tr>
<td style="text-align: center;">
<asp:TextBox ID="txtPassword" TabIndex="2" CssClass="logintext" placeholder="Password" runat="server" Columns="15"
MaxLength="15" TextMode="Password" onblur="GetTab();"></asp:TextBox>
</td>
</tr>
<tr style="padding-bottom: 30px;">
<asp:Button ID="btnVerifyOtp" runat="server" Text="Verify OTP" Style="background-color:#6cb0ef;" OnClientClick="return VerifyOtpKey();" Visible="false" />
<td style="height: 50px; padding-top: 30px; margin-bottom:50px;">
<asp:Label ID="lblOtp" runat="server" CssClass="linklabel" Style="text-align:left;padding-left:10px;" >OTP By </asp:Label>
<asp:Label ID="Label1" runat="server"
ForeColor="Red" Visible="false">*</asp:Label>
<asp:RadioButton ID="RadioEmail" runat="server" GroupName="Message" Text="Email" Style="font-size: 13px;font-weight:300px;" CssClass="linklabel" />
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="Message" Text="WhatsApp" CssClass="linklabel" Style="font-size: 13px;font-weight:300px;" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="Message" Text="SMS" CssClass="linklabel" Style="font-size: 13px;font-weight:300px;" />
<br />
<br />
<asp:Label ID="LoginSuccessfull" runat="server" CssClass="linklabel" Visible="false"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: center;">
<asp:LinkButton ID="Forgotpassword" ToolTip="Start password recovery process" runat="server"
CssClass="linklabel" Text="Forgot Password?" style="font-weight:bold;font-size:16px;color:#646464;"></asp:LinkButton>
<asp:Button ID="btnCancel" TabIndex="4" runat="server"
ToolTip="Cancel" Text="Cancel" Visible="false"></asp:Button><asp:Button ID="btnClose" TabIndex="5"
runat="server" CssClass="CommandButton" ToolTip="Close" Text="Close" Visible="false"></asp:Button>
</td>
</tr>
<tr>
<td style="text-align: center;">
<asp:Button ID="cmdLogin" TabIndex="4" CssClass="login_btn" runat="server" ToolTip="Click here to Login..."
Text="Login" Visible="true"></asp:Button>
<asp:Button ID="hdnNavigate" TabIndex="4" CssClass="loginbutton" runat="server" Visible="false"
Text="Login"></asp:Button>
</td>
</tr>
<tr>
<td style="text-align: center;font-size:16px;margin-top:20px!important;">
<asp:LinkButton ID="RegisterNewKey" ToolTip="Register New License key" runat="server"
CssClass="linklabel" style="color:#646464;font-size:16px" Text="Register New License Key"></asp:LinkButton>
</td>
</tr>
<tr>
<td>
<div>
<asp:Label ID="verificationlbl" runat="server" CssClass="linklabel" Visible="false">Verification Code</asp:Label>
</div>
</td>
</tr>
<tr>
<td>
<div><!---->
<asp:TextBox ID="txtVerification" TabIndex="4" MaxLength="6" onkeydown="return validation_Id(event);" runat="server" Visible="false" CssClass="logintext" placeholder="Verification Code" ToolTip="Verification Code" Style="width: 140px; height: 20px;" Columns="15" ></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td>
<div>
<asp:Label ID="timer" runat="server" CssClass="linklabel" Visible="false">Verification Code</asp:Label>
<!-- <div id="timer" style="color: #686869;"></div> -->
</div>
</td>
</tr>
<tr>
<td >
<div>
<asp:Button ID="resend" TabIndex="2" runat="server" CssClass="loginbutton" Style="display: none;background-color:#6cb0ef!important; border:none; color:#030004;font-size:16px;font-weight:300;" ToolTip="Resend OTP" Text="Resend OTP"></asp:Button>
<!-- Resend OTP button initially hidden -->
</div>
</td>
</tr>
<tr>
<td >
<div>
<asp:Button ID="btnFetchOtp" TabIndex="2" runat="server" CssClass="loginbutton" ToolTip="Verify OTP" Text="Verify OTP" Style="width: 50px;background-color:#6cb0ef; border:none; color:#030004;font-size:16px;font-weight:300;" Visible="false"></asp:Button>
</div>
</td>
</tr>
<tr style="height: 10px;">
<td width="10px" align="left"></td>
</tr>
<tr style="height: 10px;">
<td style="text-align: center;">
<asp:Label ID="lblStatus" runat="server" CssClass="Label" ForeColor="#FFFFFF" style="font-size:20px;"></asp:Label>
</td>
</tr>
<tr style="height: 10px;">
<td style="text-align: center;">
<asp:Label ID="lblStatus1" runat="server" CssClass="Label" ForeColor="#FFFFFF" style="font-size:20px;"></asp:Label>
</td>
</tr>
</table>
<%-- <table id="welcomepage" style="text-align: center; width: 300px; margin-top: 205px;position:relative;">
<tr>
<td>
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="Welcome Back" ForeColor="white" Font-Size="large"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align:center;">
<asp:Button ID="showlogin" TabIndex="4" click="showLogin()" CssClass="loginbutton" runat="server" ToolTip="Click here to Login..."
Text="Login"></asp:Button>
<button class="submit" onclick="showLogin()">submit</button>
<asp:Button ID="Button3" TabIndex="4" CssClass="loginbutton" runat="server" Visible="false"
Text="Login"></asp:Button>
</td>
</tr>
</table>--%>
</td>
<td id="tdRight"></td>
</tr>
</table>
<div style="display: none;">
<table style="width: 99.5%; height: 100%; text-align: center;" cellspacing="0" cellpadding="0"
id="tblTop">
<tr style="height: 15%;">
<td valign="middle" id="tdImgTop" width="100%" colspan="3" style="background: Supports/Images/topbanner.gif; background-attachment: fixed; background-repeat: no-repeat; height: 60px;">
</td>
</tr>
<tr>
<td id="tdColor5" bgcolor="#59749a" width="10%">
</td>
<td width="1%">
</td>
<td width="100%" id="tdSplash" rowspan="14" colspan="3"
style="background: Supports/Images/LoginImage.gif; background-attachment: inherit; background-repeat: no-repeat" height="100%"></td>
</tr>
<tr>
<td>
<table class="SearchTable" style="border-right: silver 1px; border-top: silver 1px; border-left: silver 1px; width: 160px; border-bottom: silver 1px; height: 80px;"
cellspacing="0" cellpadding="0" border="0">
<tr style="border-bottom: black thin solid">
<td colspan="2" id="tdColor6">
<asp:Label ID="lblLogin" Text="Login" runat="server" CssClass="Label" Font-Bold="True"
Font-Size="Small"></asp:Label>
</td>
</tr>
<tr>
<td align="right" width="39%" id="tdColor7">
<asp:Label ID="lblUser_ID" Text="User ID" CssClass="Label" runat="server"></asp:Label>
</td>
<td align="right" id="tdColor9"></td>
</tr>
<tr>
<td align="right" width="39%" id="tdColor8">
<asp:Label ID="lblPassword" Text="Password" CssClass="Label" runat="server"></asp:Label>
</td>
<td align="right" id="tdColor10"></td>
</tr>
<tr id="Tr1">
<td align="right" colspan="2">
<input class="CommandButton" id="cmdCancel" title="Click to exit from the Q-NVO"
onclick="window.close();" type="button" value="Cancel" name="cmdCancel" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 4px" align="center" bgcolor="ghostwhite"></td>
</tr>
<tr>
<td style="height: 3px" align="center" bgcolor="ghostwhite"></td>
</tr>
<tr>
<td id="tdColor1" bgcolor="#59749a">
</td>
</tr>
<tr>
<td style="height: 4px" bgcolor="ghostwhite" align="center">
<asp:Label ID="lblBTLNews" runat="server" Text="User ID" Width="100%" CssClass="Label"
Font-Bold="True">News</asp:Label>
</td>
</tr>
<tr>
<td id="tdColor2" style="height: 160px" bgcolor="#59749a">
</td>
</tr>
<tr>
<td style="height: 4px" bgcolor="ghostwhite" align="center">
<asp:Label ID="lblAnnouncement" runat="server" Text="User ID" Width="100%" CssClass="Label"
Font-Bold="True">Announcements</asp:Label>
</td>
</tr>
<tr>
<td id="tdColor3" style="height: 160px" bgcolor="#59749a">
</td>
</tr>
<tr>
<td style="height: 4px" bgcolor="ghostwhite" align="center">
<asp:Label ID="lblIndustryNews" Font-Bold="True" runat="server" Text="User ID" Width="100%"
CssClass="Label">Industry News</asp:Label>
</td>
</tr>
<tr>
<td id="tdColor4" style="height: 180px" bgcolor="#59749a">
</td>
</tr>
<tr>
<td style="height: 15%">
<input class="DescLabels" id="Text1" style="display: none; width: 24px; height: 0px"
readonly type="text" size="1" value="0" name="hdnUserIPAddress"
runat="server" />
<input class="DescLabels" id="hdnRegistrationflg" style="display: none; width: 24px; height: 0px"
readonly type="text" size="1" value="0" name="hdnRegistrationflg"
runat="server" />
<input style="display: none" id="txtShowLogin" class="DescLabels" contenteditable="false" size="1" name="txtShowLogin" runat="server" />
<input class="DescLabels" id="hdnRegistrationKey" style="display: none; width: 24px; height: 0px"
readonly type="text" size="1" value="0" name="hdnRegistrationKey"
runat="server" /><input class="DescLabels" id="hdnServerKey" style="display: none; width: 24px; height: 0px"
readonly type="text" size="1" value="0" name="hdnServerKey"
runat="server" /><input class="DescLabels" id="hdnIPAddress" style="display: none" type="text" size="1" name="hdnIPAddress"
runat="server" /><input class="DescLabels" id="hdnIPSessPrUsr" style="display: none" type="text" size="1" name="hdnIPSessPrUsr"
runat="server" /><input style="display: none" id="txtpwdExpiry" class="DescLabels" contenteditable="false" size="1" name="txtpwdExpiry" runat="server" />
<input class="DESCLABELS" id="hdnResolution" style="display: none; width: 9px; height: 22px" contenteditable="false" type="text"
size="1" name="hdnResolution" runat="server" value="1366"><input style="display: none" id="hdnOTP" class="DescLabels" contenteditable="false" size="1" name="hdnOTP" runat="server" /><input style="display: none" id="hdnSuperUserFlag" class="DescLabels" contenteditable="false" size="1" name="hdnSuperUserFlag" runat="server" />
</td>
</tr>
</table>
</div>
</form>
</div>
</body>
</html>
=========================================================================================================================================================================
then move on vb code
'***************************************************************************************************************
'* Company Name : Quantum BSO Pvt. Ltd.
'* Project Title : Feeder System
'***************************************************************************************************************
'* Client Name :
'* Configuration ID : QFLX21023 Version: 1.0.0.0
'* Form/Module Name : frmLoadingConfirm.aspx
'* Description : This Page is used to confirm the Loading
'* Created By : Goutam
'* Module/Project Leader : Rakesh
'* Created On :
'* Last Modified On : 29/05/2019
'* Last Modified By : Vijay M
'* Remarks : Added OTP Functionality
'***************************************************************************************************************
Imports System.Web.Caching
Imports System.Environment
Imports System.Net
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports RestSharp
Imports System.Threading.Tasks
Imports System.Drawing
Imports Twilio.Rest.Api.V2010.Account
Imports Twilio.Types
Imports Twilio.Rest.Client
Imports System.IO
Imports System.Text
Imports Twilio.Clients
Imports Twilio
Imports System.Configuration.ConfigurationManager
Imports prjDataAccess
Imports System.Resources
Imports System.Net.Dns
Imports System.Web.UI.Page
Imports QFLXBusinessDev
Imports System.Net.Mail
Imports System.Net.Mime
Namespace WorkFLow
Public Class frmLogin
Inherits Common
#Region "Page Variable"
Dim objUser As New QFLXBusinessDev.Master.clsUser_Mst_Tbl
Dim objclsCommon As New QFLXBusinessDev.Master.clsCommon
Dim objEmployee As New QFLXBusinessDev.Master.clsEMPLOYEE_MST_TBL
Dim objOTP As New QFLXBusinessDev.Master.clsOTP
Dim objLicenseCmn As New WorkFLow.cls_ValidateLicense
Dim objUserPref As New QFLXBusinessDev.Master.cls_User_Preference_Mst_Tbl
Dim strUsrPk As String
Dim LicenceExpiryDays As Int64
Dim LicenceDS As DataSet
Dim VCSVOYSTATUS As String
Dim ActiveClient As String = ConfigurationSettings.AppSettings("ActiveClient")
#End Region
#Region "Page Load"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
If Session("hdrRedirect") = 1 Then
hdnNavigate_Click(sender, e)
Exit Sub
End If
If Request.QueryString("errorMessage") IsNot Nothing Then
Dim errorMessage As String = Request.QueryString("errorMessage")
'LoginSuccessfull.Text = errorMessage
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You entered wrong OTP three times. Please try again.');", True)
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & errorMessage & "');", True)
Response.Redirect(Request.Url.AbsolutePath) 'redirect to the same page without the QueryString parameters
End If
'Session("UserId") = Me.txtUSER_ID.Text
'Session("Password") = Me.txtPassword.Text
RadioEmail.Checked = True
hdnOTP.Value = 0
SetStyleSheet()
If IsMultiSessionEnabled Then
Call GetIP()
End If
Forgotpassword.Attributes.Add("OnClick", "JavaScript:return OpenPwdEntry();")
hdnRegistrationflg.Value = objLicenseCmn.fn_ChkRegistrationCodeExists()
RegisterNewKey.Attributes.Add("OnClick", "JavaScript:return RegisterNewKey();")
'// verificationotp.Attributes.Add("OnClick", "JavaScript:return verificationotp();")
txtVerification.Attributes.Add("onblur", "javascript:validation_Id(this.value,'txtUserID');")
Else
If txtpwdExpiry.Value <> "" Then
If txtpwdExpiry.Value = 0 And (Session("PASSWORD_EXPIRY_DT") <> 0) Then
If Val(hdnSuperUserFlag.Value) > 0 Then
Server.Transfer("Forms/03Security/frmMainMenuX.aspx?formFlag=OverrideOTP")
Else
objEmployee.Update_OTPLimit(Val(Session("USER_PK")))
'' objEmployee.FetchUserDetails(Val(Session("MOBILE_NO")))
End If
End If
End If
End If
End Sub
#End Region
'#Region "Get OnBlur Function"
' Protected Sub OnBlur(sender As Object, e As System.EventArgs)
' //dim handler As String = ClientScript.GetPostBackEventReference(this.Button1, "");
' txtUSER_ID.Attributes.Add("onblur", );
' '//ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('OnBlur Fired.');", True)
' End Sub
'#End Region
#Region "Get IP"
Private Sub GetIP()
Try
Dim result As String = String.Empty
Dim ip As String = HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If Not String.IsNullOrEmpty(ip) Then
Dim ipRange As String() = ip.Split(","c)
Dim le As Integer = ipRange.Length - 1
hdnIPAddress.Value = ipRange(0)
Else
hdnIPAddress.Value = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
End If
If hdnIPAddress.Value.Length < 7 Then
Dim hostname As String = Dns.GetHostName()
hdnIPAddress.Value = CType(Dns.GetHostByName(hostname).AddressList.GetValue(0), IPAddress).ToString
End If
Session("SYSTEM_IP") = hdnIPAddress.Value
Catch ex As Exception
hdnIPAddress.Value = "127.0.0.1"
End Try
End Sub
#End Region
#Region "Login"
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
Dim strValidityCheckValue As String
Dim strUsrName As String
Dim strLocPk As String
Dim strDesig As String
Dim strLocName As String
Dim strCurrencyID As String
Dim strCurrencyName As String
Dim strCorpCurrencyID As String
Dim strCorpCurrencyName As String
Dim strSplitvalue As String()
Dim NewUser_Flag As String
Dim IsMultiLogin As Boolean
Dim AlertExpiryDays As Integer
Dim strQilsLocPk As String
Dim WrongPwdCount As Integer ''
Dim jscript As String
Dim usrimage As String
Dim usrimageURL As String
Dim AgentImage As String
Dim AgentImageURL As String
Dim Mobile As String
Dim Email As String
Dim Message As String
txtShowLogin.Value = 1
objLicenseCmn.objRequest = Request
objLicenseCmn.ObjApplication = Application
Session.Add("hdnScreenResolution", Val(hdnResolution.Value))
Session.Add("ROOTPATH", Server.MapPath("."))
'If (Request.Browser.Browser.ToUpper() = "IE" AndAlso Request.Browser.MajorVersion > 5) OrElse (Request.Browser.Browser.ToUpper = "NETSCAPE" AndAlso Request.Browser.MajorVersion = 5) Then
'Else
' Server.Transfer(Server.MapPath(".") & "\Forms\03Security\InvalidBrowser.htm")
'End If
If Val(hdnOTP.Value) = 0 Then
If objLicenseCmn.fn_ValidateUsers(Me, hdnRegistrationKey.Value, lblStatus, txtUSER_ID.Text, LicenceExpiryDays) = 0 Then
Session.Abandon()
Session.Clear()
lblStatus.Visible = True
Exit Sub
End If
Dim objemp As New QFLXBusinessDev.Master.clsEMPLOYEE_MST_TBL
If CInt(Session("SESSION_NO_OF_LICENSE_USERS")) > 0 Then
If objemp.fn_GetStoredUsers(CInt(Session("SESSION_NO_OF_LICENSE_USERS"))) > 0 Then
Session.Abandon()
Session.Clear()
lblStatus.Text = "Number of License Exceeds, Contact Administrator."
lblStatus.Visible = True
Exit Sub
End If
End If
If Not IsNothing(ConfigurationSettings.AppSettings("IsMultiLogin")) Then
IsMultiLogin = ConfigurationSettings.AppSettings("IsMultiLogin")
Else
IsMultiLogin = False
End If
If Not IsNothing(ConfigurationSettings.AppSettings("LicenseExpiryDays")) Then
AlertExpiryDays = CInt(ConfigurationSettings.AppSettings("LicenseExpiryDays"))
Else
AlertExpiryDays = 7
End If
''''''''''''''''''''''
strValidityCheckValue = objUser.IsUserValid(txtUSER_ID.Text.Trim, txtPassword.Text)
Select Case strValidityCheckValue
Case "0"
lblStatus.Text = GetErrorMessage(10020)
Case "1"
lblStatus.Text = GetErrorMessage(10021)
lblStatus1.Text = ""
Case "2"
lblStatus.Text = GetErrorMessage(10022)
Case "3"
lblStatus.Text = GetErrorMessage(10023)
Case "4"
lblStatus.Text = GetErrorMessage(10026)
Case "5"
lblStatus.Text = GetErrorMessage(10025)
Case "6"
lblStatus.Text = "User is InActive. Contact Administrator"
Case "7"
lblStatus.Text = "Employee is InActive. Contact Administrator"
Case "9"
lblStatus.Text = GetErrorMessage(10027)
Case Else
lblStatus.Text = ""
End Select
If strValidityCheckValue.Length > 1 Then
If IsMultiLogin = False Then
If IsUserIdExist() Then
lblStatus.Visible = True
lblStatus.Text = "User has already logged in from different location."
If Application("NUM_LOGIN_USERS") > 0 Then
Application("NUM_LOGIN_USERS") = Application("NUM_LOGIN_USERS") - 1
End If
Exit Sub
End If
CreateEntryInCache()
Else
Dim CacheEnum As IDictionaryEnumerator = Cache.GetEnumerator
Dim Key(), ExisistUser As String
While CacheEnum.MoveNext
Key = CacheEnum.Key.ToString.Split(",")
ExisistUser = Key(0)
If UCase(ExisistUser) = UCase(txtUSER_ID.Text) Then
Cache.Remove(UCase(txtUSER_ID.Text))
End If
End While
End If
strSplitvalue = Split(strValidityCheckValue, "|")
strUsrPk = strSplitvalue(1)
strUsrName = strSplitvalue(0)
strLocPk = strSplitvalue(2)
strDesig = strSplitvalue(3)
strLocName = strSplitvalue(4)
strQilsLocPk = strSplitvalue(5)
WrongPwdCount = strSplitvalue(7)
NewUser_Flag = strSplitvalue(8)
If WrongPwdCount >= 5 Then
lblStatus.Visible = True
jscript = String.Empty & vbCrLf
jscript = " <script language=javascript> "
jscript &= "var arrHeader = new Array('Search - Company'); "
jscript &= "sFeatures = 'dialogWidth:665px;status= no;resizable= yes;dialogHeight:190px;scrollable=yes;'; "
jscript &= "var strReturn = null; "
jscript &= "var url ='frmForgotPass.aspx';"
jscript &= "window.showModalDialog(url,arrHeader,sFeatures); "
jscript &= " </script> "
Response.Write(jscript)
Exit Sub
End If
'If WrongPwdCount >= 5 Then
'If
Dim Name As String
CreateCookies("UserID", txtUSER_ID.Text, Response, Request)
Session.Add("USER_PK", strUsrPk)
Session.Add("USER_ID", txtUSER_ID.Text)
Dim Empid As String = CType(Session("USER_ID"), String).ToUpper()
Mobile = objEmployee.FetchMobileNumber(Empid)
Session("Mobile") = Mobile
'Commented By Arun
'Message = objEmployee.FetchUserPreference(Empid)
' If (Message = 2) Then
' RadioButton1.Checked = True
' RadioButton2.Checked = False
' RadioEmail.Checked = False
' ElseIf (Message = 3) Then
' RadioButton1.Checked = False
' RadioButton2.Checked = True
' RadioEmail.Checked = False
' Else
' RadioButton1.Checked = False
' RadioButton2.Checked = False
' RadioEmail.Checked = True
' End If
Session("Message") = Nothing
'If (Message = 2) Then
' RadioButton1.Checked = True
'ElseIf (Message = 3) Then
' RadioButton2.Checked = True
'Else
' RadioEmail.Checked = True
'End If
Email = objEmployee.FetchEmail(Empid)
Session("EmailOtp") = Email
Session.Add("USER_NAME", strUsrName)
Session.Add("LOGED_IN_LOC_FK", strLocPk)
Session.Add("LOGED_IN_LOC_NAME", strLocName)
Session.Add("DESIGNATION", strDesig)
Session.Add("QILS_LOCATION_MST_FK", strQilsLocPk)
objUser.fn_DocumentWorkflow(Session("LOGED_IN_LOC_FK"))
If objclsCommon.IsAdministrator(Session("USER_ID")) Then
Session("IsAdmin") = 1
Else
Session("IsAdmin") = 0
End If
Dim objCurrency As New QFLXBusinessDev.Master.clsCURRENCY_TYPE_MST_TBL
Session("CURRENCY_MST_PK") = objCurrency.GetBaseCurrency(strLocPk, strCurrencyID, strCurrencyName)
Session.Add("CURRENCY_ID", strCurrencyID)
Session.Add("CURRENCY_NAME", strCurrencyName)
Session("CORP_CURRENCY_MST_PK") = objCurrency.GetCorpCurrency(strCorpCurrencyID, strCorpCurrencyName)
Session.Add("CORP_CURRENCY_ID", strCorpCurrencyID)
Session.Add("CORP_CURRENCY_NAME", strCorpCurrencyName)
Session.Add("EMP_PK", objUser.FetchEmpForUser(strUsrPk))
Session.Add("Cust_PK", objUser.FetchCustForUser(strUsrPk))
Session.Add("Role_PK", objUser.FetchROLEForUser(strUsrPk))
Session.Add("QNVOBUSINESS_MODEL", 4)
Dim objPref As New QFLXBusinessDev.Master.cls_User_Preference_Mst_Tbl
Session.Add("STYLESHEET", objPref.FetchStyleSheet(CDbl(strUsrPk)))
Session.Add("DATE_FORMAT", objPref.GetDateFormat(CDbl(strUsrPk)))
Session.Add("ENVIRONMENT_PK", objPref.GetLanguageOption(CDbl(strUsrPk)))
'Globalization Code
Session.Add("LANG", objPref.GetLanguageDetail(CDbl(strUsrPk)))
Session.Add("REGIONFORMAT", objPref.GetRegionalFormat(CDbl(strUsrPk)))
Session.Add("NUM_THOU_SEP", GetNumFormatInfo.NumberGroupSeparator)
Session.Add("NUM_DEC_SEP", GetNumFormatInfo.NumberDecimalSeparator)
Session.Add("NUM_DEC_LEN", GetNumFormatInfo.NumberDecimalDigits)
Session.Add("SHORTDATEPATTERN", GetDateTimeFormatInfo.ShortDatePattern)
Session.Add("SHORTTIMEPATTERN", GetDateTimeFormatInfo.ShortTimePattern)
Session.Add("DATEPATTERN", GetDateTimeFormatInfo.ShortDatePattern)
Session.Add("DATESEPARATOR", GetDateTimeFormatInfo.DateSeparator)
'****************************************
''''''''''''''
Session.Add("PASSWORD_EXPIRY_DT", objPref.GetPasswordExpiryDate(CDbl(strUsrPk)))
Session.Add("EXP_NOTIFICATION_DT", objPref.GetPasswordAlertDate(CDbl(strUsrPk)))
Session.Add("CONTR_EXPIRY_ALERT_DAYS", objPref.GetContractExpAlertDays(CDbl(strUsrPk)))
Session.Add("BROWSERTYPE", Request.Browser.Browser.ToUpper())
Session.Add("PARAMETER_VALUE", objPref.GetParameterValue())
Session.Add("GALAXY_URL", objPref.GetParamGalaxyUrlValue())
Session.Add("BROWSERVERSION", Request.Browser.Version.ToString())
usrimage = objPref.FetchUserImage(CDbl(strUsrPk))
Session.Add("HQ_USER_FLAG", objUser.FetchHQEmp(strUsrPk))
Session.Add("FIN_ENTITY_FLAG", objPref.GetFinance_EntityFlag())
Session.Add("ADVATOS_ENABLE", objPref.GetADVATOSFlag())
Session.Add("DOC_NO_GENERATE_FLAG", objPref.GetDOC_NO_GENERATE_FLAG())
Session.Add("ACTIVECLIENT", ActiveClient)
If usrimage <> " " Then
'usrimageURL = Request.Url.ToString().Replace("frmLogin.aspx", "Supports/UserImages/") + usrimage
'Session.Add("USER_IMG_URL", usrimageURL)
usrimageURL = Request.Url.ToString().Replace("frmLogin.aspx", "Supports/Images/NewImages/user-image.png")
Session.Add("USER_IMG_URL", usrimageURL)
Else
usrimageURL = Request.Url.ToString().Replace("frmLogin.aspx", "Supports/Images/NewImages/user-image.png")
Session.Add("USER_IMG_URL", usrimageURL)
End If
AgentImage = objPref.FetchAgentImage()
If AgentImage <> " " Then
AgentImageURL = Request.Url.ToString().Replace("frmLogin.aspx", "Logos/") + AgentImage
Session.Add("AGENT_IMG_URL", AgentImageURL)
Else
usrimageURL = Request.Url.ToString().Replace("frmLogin.aspx", "Logos/QuantumLogo.jpg")
Session.Add("AGENT_IMG_URL", AgentImageURL)
End If
Session.Add("HDR_CLICK", "Mail")
Session.Add("hdrRedirect", 0)
Session.Add("SitePageURL", " ")
Session.Add("SitePageQS", " ")
''''''''''''''
If NewUser_Flag = 1 Then
jscript = String.Empty & vbCrLf
jscript = " <script language=javascript> "
jscript &= "var arrHeader = new Array('Search - Company'); "
jscript &= "sFeatures = 'dialogWidth:665px;status= no;resizable= yes;dialogHeight:190px;scrollable=yes;'; "
jscript &= "var strReturn = null; "
jscript &= "var url ='Forms/03Security/frmChangePassword.aspx';"
jscript &= "window.showModalDialog(url,arrHeader,sFeatures); "
jscript &= " </script> "
Response.Write(jscript)
Exit Sub
'Server.Transfer("Forms/03Security/frmChangePassword.aspx?EMPPK=" & CInt(strUsrPk))
End If
Dim IsUserPresent As Integer = objPref.IsUserAvailable(strUsrPk)
If IsUserPresent = 1 Then
Session.Add("GRID_RECORD_SIZE", objPref.FetchNumberOfRecords(strUsrPk))
'Session.Add("GRID_RECORD_SIZE", "2")
Session.Add("List_OnLoad", objPref.FetchListOnLoad(strUsrPk))
Session.Add("Date_OnLoad", objPref.FetchDateLoad(strUsrPk))
If Session("Date_OnLoad") = 1 Then
Session.Add("User_Preference_Date", objPref.FetchPrefDate(strUsrPk))
End If
ElseIf IsUserPresent = 0 Then
Session.Add("GRID_RECORD_SIZE", "15")
Session.Add("List_OnLoad", "0")
End If
Try
LicenceDS = objPref.FetchLicenceExipiry(strUsrPk, LicenceExpiryDays)
If LicenceExpiryDays <= AlertExpiryDays And LicenceDS.Tables(0).Rows.Count = 0 Then
For Each _row As DataRow In LicenceDS.Tables(1).Rows
For Each _col As DataColumn In LicenceDS.Tables(1).Columns
_row(_col.ColumnName) = IIf(IsDBNull(_row(_col.ColumnName)), "", _row(_col.ColumnName).ToString())
Next
SendMail(_row.Item("EMAIL_ID"), _row.Item("EMAIL_SUBJECT"),
_row.Item("EMAIL_BODY"), _row.Item("CC_EMAIL_ID"),
"", , , , , , 0)
Next
SendMail(M_INTERNAL_EMAILID, LicenceDS.Tables(1).Rows(0).Item("EMAIL_SUBJECT"),
LicenceDS.Tables(1).Rows(0).Item("EMAIL_BODY"), LicenceDS.Tables(1).Rows(0).Item("CC_EMAIL_ID"),
"", , , , , , 0)
End If
Catch ex As Exception
End Try
objPref = Nothing
If IsActivityLogEnabled Then
Dim objLoginDet As New QFLXBusinessDev.Master.cls_UserActivity
objLoginDet.fn_SaveLoginDetails(strLocPk, Session("USER_PK"), Session("USERSESSION_ID"), fun_getTimeZoneDateTime, , hdnIPAddress.Value)
End If
'*******Data Archieve*******
Dim objPref1 As New QFLXBusinessDev.Master.cls_User_Preference_Mst_Tbl
objPref1.UpdateTransactions(strUsrPk)
Session("UserId") = Me.txtUSER_ID.Text
Session("Password") = Me.txtPassword.Text
'To check for Password Expiry
Dim NoOfDays As Int32
Dim PassExp As Int32
Dim passdate As Date
PassExp = Session("PASSWORD_EXPIRY_DT")
Dim daysAlert As Int32
daysAlert = Session("EXP_NOTIFICATION_DT")
If Session("EXP_NOTIFICATION_DT") = "0" Then
daysAlert = "0"
End If
passdate = objUser.chkpasswordExpiry(CType(strUsrPk, Long))
NoOfDays = (DateDiff(DateInterval.Day, passdate, Date.Now))
If (daysAlert <= NoOfDays And NoOfDays < PassExp) Then
jscript = String.Empty & vbCrLf
jscript = " <script language=javascript> "
jscript &= " top.window.moveTo(0, 0);"
jscript &= " if (document.all) {"
jscript &= " SetWidth(window.screen.width, window.screen.height);"
jscript &= " top.window.resizeTo(window.screen.width, window.screen.height);"
jscript &= " }"
jscript &= " else if (document.layers || document.getElementById) {"
jscript &= " SetWidth(top.window.outerWidth, top.window.outerHeight);"
jscript &= " if (top.window.outerHeight < availHeight || top.window.outerWidth < availWidth) {"
jscript &= " top.window.outerHeight = availHeight;"
jscript &= " top.window.outerWidth = availWidth;"
jscript &= " }"
jscript &= " }"
jscript &= " if(confirm('Your password will expire in " & PassExp - NoOfDays & " days.\n Would you like to change your password?')){"
jscript &= "var arrHeader = new Array('Search - Company'); "
jscript &= "sFeatures = 'dialogWidth:665px;status= no;resizable= yes;dialogHeight:190px;scrollable=yes;'; "
jscript &= "var strReturn = null; "
jscript &= "var url ='Forms/03Security/frmChangePassword.aspx';"
jscript &= "window.showModalDialog(url,arrHeader,sFeatures); "
jscript &= "document.getElementById('" & txtpwdExpiry.ClientID & "').value = 1;"
jscript &= "}"
jscript &= "else { document.getElementById('" & txtpwdExpiry.ClientID & "').value = 0;__doPostBack('cmdLogin','OnClick');}"
jscript &= " </script> "
Page.RegisterStartupScript("clientScript", jscript)
Exit Sub
Else
txtpwdExpiry.Value = 0
End If
If CheckPasswordExpiry(txtUSER_ID.Text.ToUpper()) = True And txtpwdExpiry.Value = 0 Then
VCSVOYSTATUS = objEmployee.Fetch_VCSVOYStatus()
If VCSVOYSTATUS = "2" Then
objEmployee.VCSVOYStatusUPD()
End If
Dim CustTaxStatus As String
CustTaxStatus = objEmployee.UpdateCustomerTaxValidity()
Dim EnableOTP As Boolean = False
Dim EnableSMS As Boolean = False
If Not IsNothing(ConfigurationSettings.AppSettings("EnableOTP")) Then
EnableOTP = ConfigurationSettings.AppSettings("EnableOTP")
End If
If Not IsNothing(ConfigurationSettings.AppSettings("OTPSMSFlag")) Then
EnableSMS = ConfigurationSettings.AppSettings("OTPSMSFlag")
End If
If EnableOTP = True And objUser.chkOTPEnable(Val(strUsrPk)) = 1 Then
Dim dsUser As New DataSet
dsUser = objOTP.Get_OTPMailDetails(Val(Session("USER_PK")), "OTP_USER")
If dsUser.Tables(0).Rows.Count > 0 Then
dsUser = Nothing
dsUser = objEmployee.Get_SuperUserDetails()
If dsUser.Tables(0).Rows.Count > 0 Then
If Val(dsUser.Tables(0).Rows(0).Item("USER_ENTERED_LIMIT")) >= Val(dsUser.Tables(0).Rows(0).Item("OTP_ATTEMPT_LIMIT")) Then
'Server.Transfer("Forms/03Security/frmOverrideOTP.aspx?formFlag=OverrideOTP")
SetStyleSheet()
'Server.Transfer("Forms/03Security/frmOTHMainMenu1X.aspx?formFlag=OverrideOTP") 'frmOTHMainMenu1X.aspx
'Server.Transfer("Forms/03Security/frmMainMenuX.aspx?formFlag=OverrideOTP")
Server.Transfer("frmOverrideOTP.aspx?formFlag=OverrideOTP")
End If
End If
If EnableSMS = True Then
Server.Transfer("frmQILSLogin.aspx")
End If
lblStatus.Visible = True
jscript = String.Empty & vbCrLf
jscript = " <script language=javascript> "
jscript &= " top.window.moveTo(0, 0);"
jscript &= " if (document.all) {"
jscript &= " SetWidth(window.screen.width, window.screen.height);"
jscript &= " top.window.resizeTo(window.screen.width, window.screen.height);"
jscript &= " }"
jscript &= " else if (document.layers || document.getElementById) {"
jscript &= " SetWidth(top.window.outerWidth, top.window.outerHeight);"
jscript &= " if (top.window.outerHeight < availHeight || top.window.outerWidth < availWidth) {"
jscript &= " top.window.outerHeight = availHeight;"
jscript &= " top.window.outerWidth = availWidth;"
jscript &= " }"
jscript &= " }"
jscript &= "var arrHeader = new Array('Search - OTP'); "
If EnableSMS = True Then
jscript &= "sFeatures = 'dialogWidth:865px;status= no;resizable= no;dialogHeight:490px;scrollable=no;toolbar=no;menubar=no;location=no;';"
jscript &= "var url ='frmOTPNew.aspx';"
Else
jscript &= "sFeatures = 'dialogWidth:665px;status= no;resizable= no;dialogHeight:140px;scrollable=no;toolbar=no;menubar=no;location=no;'; "
jscript &= "var url ='frmOTP.aspx';"
End If
jscript &= "var strReturn = window.showModalDialog(url,arrHeader,sFeatures); "
jscript &= " if(strReturn==1){document.getElementById('" & hdnOTP.ClientID & "').value = 1;__doPostBack('cmdLogin','OnClick');}"
jscript &= " else if(strReturn==2) { document.getElementById('" & hdnOTP.ClientID & "').value = 0; document.getElementById('" & hdnSuperUserFlag.ClientID & "').value = 1; __doPostBack('cmdLogin','OnClick');}"
jscript &= " else {window.parent.navigate('frmLogin.aspx');}"
jscript &= " </script> "
Page.RegisterStartupScript("clientScript", jscript)
Exit Sub
Else
End If
End If
LoginSuccessfull.Visible = True
'LoginSuccessfull.Text = "Otp has been sent on your mobile number and email"
Dim suppressOtp As Boolean = Boolean.Parse(ConfigurationManager.AppSettings("SuppressOtp"))
If suppressOtp Then
Server.Transfer("Forms/03Security/frmMainMenuX.aspx")
Else
OtpBy_Click(sender, e)
End If
txtUSER_ID.Visible = True
txtPassword.Visible = True
RadioButton1.Visible = True
RadioButton2.Visible = True
Forgotpassword.Visible = False
RegisterNewKey.Visible = False
'verificationotp.Visible = False
RadioEmail.Visible = True
RadioButton1.Visible = True
RadioButton2.Visible = True
'btnCancel.Visible = True
btnClose.Visible = False
lblOtp.Visible = True
btnCancel.Visible = False
Else
lblStatus.Visible = True
jscript = String.Empty & vbCrLf
jscript = " <script language=javascript> "
jscript &= "var arrHeader = new Array('Search - Company'); "
jscript &= "sFeatures = 'dialogWidth:665px;status= no;resizable= yes;dialogHeight:190px;scrollable=yes;'; "
jscript &= "var strReturn = null; "
jscript &= "var url ='Forms/03Security/frmChangePassword.aspx';"
jscript &= "window.showModalDialog(url,arrHeader,sFeatures); "
jscript &= " </script> "
Response.Write(jscript)
Exit Sub
End If
Else
lblStatus.Visible = True
End If
Else
Server.Transfer("Forms/03Security/frmMainMenuX.aspx")
End If
End Sub
#End Region
#Region "hdnNavigate"
Private Sub hdnNavigate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hdnNavigate.Click
Session("hdrRedirect") = 0
Server.Transfer("Forms/03Security/frmMainMenuX.aspx")
'QILSOCEANIC/Forms/01Setup/frmDashboardInbox.aspx?PK_Value=1
End Sub
#End Region
#Region "CheckPasswordExpiry"
Public Function CheckPasswordExpiry(ByVal user_id As String) As Boolean
Dim passdate As Date
Dim NoOfDays As Int32
Dim PassExp As Int32
PassExp = Session("PASSWORD_EXPIRY_DT")
Dim daysAlert As Int32
daysAlert = Session("EXP_NOTIFICATION_DT")
If Session("EXP_NOTIFICATION_DT") = "0" Then
daysAlert = "0"
End If
Dim jscript As String
CheckPasswordExpiry = True
Try
If NoOfDays >= PassExp Then
lblStatus.Text = "Your password has expired. Please contact the administrator"
CheckPasswordExpiry = False
lblStatus.Visible = True
Exit Function
End If
Catch ex As Exception
Throw ex
End Try
End Function
#End Region
#Region "Cache Object"
Private Function CreateEntryInCache()
Dim OnRemove As CacheItemRemovedCallback
OnRemove = New CacheItemRemovedCallback(AddressOf Me.RemoveEntryFromCache)
Cache.Insert(
UCase(txtUSER_ID.Text),
Request.ServerVariables("remote_addr"),
Nothing,
Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(Session.Timeout),
Caching.CacheItemPriority.High,
OnRemove
)
End Function
Private Sub RemoveEntryFromCache(ByVal Key As String, ByVal Val As Object, ByVal Reason As Caching.CacheItemRemovedReason)
'Session.Clear()
'Session.Abandon()
End Sub
Private Function IsUserIdExist() As Boolean
Dim CacheEnum As IDictionaryEnumerator = Cache.GetEnumerator
Dim Key(), LoggedInUser As String
While CacheEnum.MoveNext
Key = CacheEnum.Key.ToString.Split(",")
LoggedInUser = Key(0)
If UCase(LoggedInUser) = UCase(txtUSER_ID.Text) Then
Return True
End If
End While
Return False
End Function
#End Region
#Region "Otp by Email ,SMS and Whatsapp"
'for UltraMsg
Function GetInstanceSettings() As Tuple(Of String, String)
Dim instanceId As String = ConfigurationManager.AppSettings("InstanceId")
Dim token As String = ConfigurationManager.AppSettings("Token")
Return Tuple.Create(instanceId, token)
End Function
'for Twilio
Function GetTwilioSettings() As Tuple(Of String, String, String)
Dim accountSid As String = ConfigurationManager.AppSettings("AccountSid")
Dim authToken As String = ConfigurationManager.AppSettings("AuthToken")
Dim messagingServiceSid As String = ConfigurationManager.AppSettings("MessagingServiceSid")
Return Tuple.Create(accountSid, authToken, messagingServiceSid)
End Function
Function GetEmailSettings() As Tuple(Of String, String, String)
Dim fromAddress As String = ConfigurationManager.AppSettings("FromAddress")
Dim fromPassword As String = ConfigurationManager.AppSettings("FromPassword")
Dim smtpServer As String = ConfigurationManager.AppSettings("SmtpServer")
Return Tuple.Create(fromAddress, fromPassword, smtpServer)
End Function
Protected Sub OtpBy_Click(sender As Object, e As EventArgs)
' Get user ID from input field and store in session
Session.Add("USER_ID", txtUSER_ID.Text)
Dim Empid As String = CType(Session("USER_ID"), String).ToUpper()
' Get user's mobile number and email from database
Dim Mobile As String = objEmployee.FetchMobileNumber(Empid)
Dim Email As String = objEmployee.FetchEmail(Empid)
Dim FetchinstanceId As String
Dim Fetchtoken As String
'for UltraMsg
Dim settings As Tuple(Of String, String) = GetInstanceSettings()
Dim instanceId As String = settings.Item1
Dim token As String = settings.Item2
'for twilio
Dim settings1 As Tuple(Of String, String, String) = GetTwilioSettings()
Dim accountSid As String = settings1.Item1
Dim authToken As String = settings1.Item2
Dim messagingServiceSid As String = settings1.Item3
'for Gmail
Dim emailSettings As Tuple(Of String, String, String) = GetEmailSettings()
Dim fromAddress As String = emailSettings.Item1
Dim fromPassword As String = emailSettings.Item2
Dim smtpServer As String = emailSettings.Item3
'txtShowOtp.Value = 1
Dim EmployeeMobile As String = CType(Session("Mobile"), String)
Dim EmployeeEmail As String = CType(Session("EmailOtp"), String)
' Validate that a valid endpoint (either mobile or email) is available
If String.IsNullOrEmpty(Mobile) AndAlso String.IsNullOrEmpty(Email) Then
txtShowLogin.Value = 1
' Display error message if no valid endpoint is available
lblStatus.Text = "Email/Phone Number Not configured."
lblStatus1.Text = " Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
LoginSuccessfull.Text = ""
If String.IsNullOrEmpty(Mobile) Then
' Display error message if mobile number is not available
lblStatus.Text = "Mobile number not configured."
lblStatus1.Text = " Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
LoginSuccessfull.Text = ""
End If
If String.IsNullOrEmpty(Email) Then
' Display error message if email address is not available
lblStatus.Text = "Email not configured. "
lblStatus1.Text = "Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
LoginSuccessfull.Text = ""
End If
Else
' Generate OTP
Dim otp As String = New Random().Next(100000, 999999).ToString()
Session("otp") = otp
Dim otpExpiration As Integer = Integer.Parse(ConfigurationManager.AppSettings("OTPExpiration"))
Dim otpExpirationDateTime As DateTime = DateTime.Now.AddSeconds(otpExpiration)
Session("OTPExpiration") = otpExpirationDateTime
Dim mobileOtp As String = EmployeeMobile
Dim message As String = otp & " is your One time password (OTP) to login to QILS. Don't share OTP with anyone. Please enter the OTP to proceed."
' Send OTP via available endpoint (either mobile or email)
If Not String.IsNullOrEmpty(Mobile) AndAlso RadioButton1.Checked Then
' Send OTP via SMS if mobile number is available and SMS radio button is selected
Try
Dim Otpclient As New RestClient("https://api.ultramsg.com/" & instanceId & "/messages/chat")
Dim request As New RestRequest(Method.POST)
request.AddHeader("content-type", "application/x-www-form-urlencoded")
request.AddParameter("token", token)
request.AddParameter("to", mobileOtp)
request.AddParameter("body", message)
Dim response As IRestResponse = Otpclient.Execute(request)
Dim statusCode As HttpStatusCode = response.StatusCode
Dim output As String = response.Content
Session("otp") = otp
Session("OTPExpiration") = otpExpirationDateTime
'Label1.Text = "Your Otp has been sent on your WhatsApp"
'verificationSection.Attributes("style") = "display: block"
' Display success message with masked mobile number
LoginSuccessfull.Text = "An OTP is sent to your Mobile Nr. through WhatsApp : " & String.Concat("**********", Mobile.Substring(Mobile.Length - 2))
cmdLogin.Visible = False
timer.Visible = True
verificationlbl.Visible = True
txtVerification.Visible = True
btnFetchOtp.Visible = True
lblStatus1.Text = ""
Catch ex As Exception
' Handle error sending SMS
LoginSuccessfull.Text = "There was an error sending your OTP via SMS. Please try again later or contact support."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
End Try
ElseIf Not String.IsNullOrEmpty(Mobile) AndAlso RadioButton2.Checked Then
Try
ServicePointManager.SecurityProtocol = DirectCast(3072, SecurityProtocolType)
TwilioClient.Init(accountSid, authToken)
Dim messageOptions As New CreateMessageOptions(New PhoneNumber(EmployeeMobile))
messageOptions.MessagingServiceSid = messagingServiceSid
messageOptions.Body = otp & " is your One time password (OTP) to login to QILS. Don't share OTP with anyone. Please enter the OTP to proceed."
Dim message1 = MessageResource.Create(messageOptions)
Session("otp") = otp
Session("OTPExpiration") = otpExpirationDateTime
'''''Email Send''''''''
' Display success message with masked mobile number
LoginSuccessfull.Text = "An OTP is sent to your Mobile Nr. through SMS: " & String.Concat("**********", Mobile.Substring(Mobile.Length - 2))
cmdLogin.Visible = False
timer.Visible = True
lblStatus1.Text = ""
verificationlbl.Visible = True
txtVerification.Visible = True
btnFetchOtp.Visible = True
Catch ex As Exception
' Handle error sending SMS
lblStatus.Text = "There was an error sending your OTP via SMS.Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
End Try
ElseIf Not String.IsNullOrEmpty(Email) AndAlso RadioEmail.Checked Then
' Send OTP via email if email address is available and Email radio button is selected
Try
'''''Email Send''''''''
Dim subject As String = "OTP for QILS login"
Dim body As String = otp & " is your One time password (OTP) to login to QILS. Don't share OTP with anyone. Please enter the OTP to proceed."
' Mail message
Dim messages As New MailMessage(fromAddress, EmployeeEmail, subject, body)
' SMTP client
Dim client As New SmtpClient("smtp.gmail.com", 587)
client.Credentials = New NetworkCredential(fromAddress, fromPassword)
client.EnableSsl = True
' Send the email
client.Send(messages)
Dim emailSplit As String() = Email.Split("@"c)
Dim newSplit As String() = emailSplit(1).Split("."c)
Dim array1 As Char() = emailSplit(0).ToCharArray()
Dim array2 As Char() = newSplit(0).ToCharArray()
Dim output As String = ""
For i As Integer = 0 To array1.Length - 1
If i = array1.Length - 1 OrElse i = array1.Length - 2 Then
output += array1(i)
Else
output += "*"
End If
Next
output += "@"
For i As Integer = 0 To array2.Length - 1
output += "*"
Next
For i As Integer = 1 To newSplit.Length - 1
output += "." & newSplit(i)
Next
' Display success message with masked email address and OTP
LoginSuccessfull.Text = "An OTP is sent to your Email ID: " & output & ". "
Session("otp") = otp
Session("OTPExpiration") = otpExpirationDateTime
cmdLogin.Visible = False
timer.Visible = True
verificationlbl.Visible = True
txtVerification.Visible = True
btnFetchOtp.Visible = True
lblStatus1.Text = ""
Catch ex As Exception
' Handle error sending email
LoginSuccessfull.Text = "There was an error sending your OTP via email. Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
End Try
Else
txtShowLogin.Value = 1
' Display error message if selected endpoint is not available
'lblStatus.Text = "Email/Phone Number Not configured. Please contact Administrator."
'timer.Visible = False
'cmdLogin.Visible = True
If String.IsNullOrEmpty(Mobile) Then
' Display error message if mobile number is not available
lblStatus.Text = "Mobile number not configured."
lblStatus1.Text = "Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
LoginSuccessfull.Text = ""
End If
If String.IsNullOrEmpty(Email) Then
' Display error message if email address is not available
lblStatus.Text = "Email not configured."
lblStatus1.Text = "Please contact Administrator."
cmdLogin.Visible = True
timer.Visible = False
verificationlbl.Visible = False
txtVerification.Visible = False
btnFetchOtp.Visible = False
LoginSuccessfull.Text = ""
End If
End If
End If
End Sub
Protected Sub btnFetchOtp_Click(sender As Object, e As EventArgs) Handles btnFetchOtp.Click
Dim Mobile As String = CType(Session("Mobile"), String)
Try
Dim otpCounter As Integer = Convert.ToInt32(Session("OTPCounter"))
Dim enteredOtp As String = txtVerification.Text
Dim storedOtp As String = CType(Session("otp"), String)
Dim expirationTime As DateTime = DirectCast(HttpContext.Current.Session("OTPExpiration"), DateTime)
'Dim jscript As String
If enteredOtp = storedOtp Then
If DateTime.Now < expirationTime Then
lblmsg.ForeColor = Color.DarkGreen
lblmsg.Text = "OTP matched. Authentication Successful. Please close button click !!"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Login Successfull.');", True)
Server.Transfer("Forms/03Security/frmMainMenuX.aspx")
Else
lblmsg.Attributes("style") = "display: block"
lblmsg.ForeColor = Color.DarkRed
'lblStatus.Text = "OTP has been expired .Please resend Otp."
'lblmsg.Text =
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('OTP has been expired .Please resend Otp.');", True)
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenWindow", "window.open('frmLogin.aspx','_blank');", True)
Server.Transfer("~/frmLogin.aspx")
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('OTP has been expired .Please resend Otp.');", True)
'mobileSection.Attributes("style") = "display: block"
End If
Else
' OTP verification failed
Dim attempts As Integer = Convert.ToInt32(Session("OTPAttempts"))
Dim maxAttempts As Integer = Convert.ToInt32(ConfigurationManager.AppSettings("MaxOTPAttempts"))
Dim spaceenteredOTP As String = txtVerification.Text.Trim()
If String.IsNullOrWhiteSpace(spaceenteredOTP) Then
' User entered space as OTP, increase counter
otpCounter += 1
If otpCounter = maxAttempts Then
Dim errorMessage As String = String.Format("You entered wrong OTP {0} times. Please try again.", maxAttempts)
'Dim errorMessage As String = "You entered wrong OTP three times. Please try again."
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & errorMessage & "');", True)
' User entered wrong OTP three times, display error and reset counter
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You entered wrong OTP three times. Please try again.');", True)
'btnFetchOtp.Attributes.Add("OnClick", "Javascript:return ChkMandatory();")
Response.Redirect("~/frmLogin.aspx?errorMessage=" & Server.UrlEncode(errorMessage))
otpCounter = 0
End If
Session("OTPCounter") = otpCounter ' Update the session variable
End If
If txtVerification.Text.Trim IsNot "" Then
attempts += 1
End If
If attempts >= maxAttempts Then
' Max attempts reached, navigate to login screen
' User entered wrong OTP maxAttempts times, display error and navigate to login page
Dim errorMessage As String = String.Format("You entered wrong OTP {0} times. Please try again.", maxAttempts)
'Dim errorMessage As String = "You entered wrong OTP three times. Please try again."
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & errorMessage & "');", True)
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You entered wrong OTP " & maxAttempts & " times. Please try again.');", True)
Session("OTPAttempts") = Nothing
Response.Redirect("~/frmLogin.aspx?errorMessage=" & Server.UrlEncode(errorMessage))
Else
' Update attempts count and display error message
Session("OTPAttempts") = attempts
'lblmsg.ForeColor = Color.Red
LoginSuccessfull.Text = "Sorry, the OTP you have entered is wrong"
If txtVerification.Text.Trim = "" Then
LoginSuccessfull.Text = "Please enter Verification Code."
' Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Please enter Verification Code.');", True)
End If
' Correct OTP, reset counter and proceed with login
txtVerification.Text = ""
cmdLogin.Visible = False
timer.Visible = True
verificationlbl.Visible = True
txtVerification.Visible = True
btnFetchOtp.Visible = True
End If
End If
Catch ex As Exception
lblmsg.Text = ex.Message
End Try
End Sub
Protected Sub resend_Click(sender As Object, e As EventArgs) Handles resend.Click
Dim Mobile As String = CType(Session("Mobile"), String)
Try
OtpBy_Click(sender, e)
Catch ex As Exception
lblmsg.Text = ex.Message
End Try
txtVerification.Text = ""
If lblStatus.Text = "Email/Phone Number Not configured. Please contact Administrator." Then
lblStatus.Text = " "
LoginSuccessfull.Text = "Email/Phone Number Not configured. Please contact Administrator."
cmdLogin.Visible = True
verificationlbl.Visible = False
txtVerification.Visible = False
timer.Visible = False
btnFetchOtp.Visible = False
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
txtVerification.Text = ""
lblmsg.Text = ""
End Sub
Protected Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Server.Transfer("~/frmLogin.aspx")
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "CloseDialog", "Close();", True)
End Sub
#End Region
End Class
End Namespace
===============================================================================================================================================
after thar we move on Web config file .
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
</configSections>
<!--For token Configuration for twilio-->
<!-- <add key="AccountSid" value=" " />
<add key="AuthToken" value=" " />
<add key="MessagingServiceSid" value=" " />-->
<add key="AccountSid" value=" " />
<add key="AuthToken" value=" " />
<add key="MessagingServiceSid" value=" " />
<!--For token Configuration for EmailNew-->
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
=====================================================================================
lastly same as for Ultra Message
</p>
</body>
</html>
Comments
Post a Comment