var DISPLAYMODE_LOGIN = 1;
var DISPLAYMODE_VERIFICATION = 2;
var DISPLAYMODE_PASSWORD = 3;
var crudLogin$ = null;
var crudLogin = null, mainForm = null;
var userDetail;// login context
var fldDomain, fldLogin, fldCaptcha, fldPassword, fldNewPassword1, fldNewPassword2;
var formMode;// form mode : NORMAL, FORGOTPASSWORD, FORGOT2FA
var tempPwd = null;
var newCaretPosition = null;
function initializeLogin() {
var lFormConfig = {"fieldGroups":{"userdetails":["domain","login"],"insert":["domain","login","password","encPassword","newPassword1","encNewPassword1","newPassword2","encNewPassword2","mode","passwordIndex","details","securityQuestions","securityAnswers","captcha","otp","factor"],"update":["domain","login","password","encPassword","newPassword1","encNewPassword1","newPassword2","encNewPassword2","mode","passwordIndex","details","securityQuestions","securityAnswers","captcha","otp","factor"]},"other":null,"name":"LoginRequest","fields":[{"notNull":true,"dataType":"STRING","name":"domain","pattern":"^[ -~]*$","notBlank":true,"label":"Domain","maxLength":30,"conversion":["toUpper"]},{"notNull":true,"dataType":"STRING","name":"login","pattern":"^[ -~]*$","notBlank":true,"label":"Login Id","maxLength":50,"conversion":["toUpper"]},{"notNull":true,"dataType":"STRING","name":"password","pattern":"^[ -~]*$","notBlank":true,"label":"Password","maxLength":30},{"dataType":"STRING","name":"encPassword","pattern":"^[ -~]*$","label":"EncPassword"},{"dataType":"STRING","name":"newPassword1","pattern":"^[ -~]*$","label":"New Password","maxLength":30},{"dataType":"STRING","name":"encNewPassword1","pattern":"^[ -~]*$","label":"EncNewPassword1"},{"dataType":"STRING","name":"newPassword2","pattern":"^[ -~]*$","label":"Reenter Password","maxLength":30},{"dataType":"STRING","name":"encNewPassword2","pattern":"^[ -~]*$","label":"EncNewPassword2"},{"dataType":"INTEGER","name":"mode","label":"Mode"},{"dataType":"INTEGER","name":"passwordIndex","label":"PasswordIndex"},{"dataType":"STRING","name":"details","pattern":"^[ -~]*$","label":"Details","maxLength":100},{"allowMultiple":true,"dataType":"STRING","name":"securityQuestions","pattern":"^[ -~]*$","label":"SecurityQuestions","maxLength":30},{"allowMultiple":true,"dataType":"STRING","name":"securityAnswers","pattern":"^[ -~]*$","label":"Answer to Question","maxLength":30},{"dataType":"STRING","name":"captcha","pattern":"^[ -~]*$","label":"Captcha"},{"dataType":"STRING","name":"otp","pattern":"^[ -~]*$","label":"Otp"},{"dataType":"INTEGER","name":"factor","label":"Factor"}],"desc":null};
var lConfig = {
resource: "login",
new: true,
preSaveHandler: function(pData) {
//pData.password = tempPwd;
pData.encPassword = encodePassword(pData.password, userDetail);
//pData.encPassword = CryptoJS.SHA1(CryptoJS.SHA1(pData.password)+userDetail.salt).toString();
pData.password = "";
pData.factor = 1;
if (userDetail.questions) {
pData.factor=2;
appendAnswers(pData);
}
return pData;
},
postSaveHandler: function(pObj) {
$('#btnLogin').prop('disabled',false);
if (pObj.questions) {
$.extend(userDetail,pObj);
setDisplayMode(DISPLAYMODE_PASSWORD);
return false;
}
if (pObj.status=='F') {
if (pObj.captcha) {
setCaptcha('N');
userDetail.captcha = true;
}
alert(pObj.reason, "null Failed");
} else {
if ((pObj.reason != null) && (pObj.reason != '')) {
alert(pObj.reason, "Login Message", function() {
if (pObj.status=='P') {
setChangePassword();
} else if (pObj.status=='C') {
sessionStorage.clear();
location.href = "login";
}
});
}
if (pObj.status=='S') {
fldPassword.setValue(null);
closeRemotePage();
postLogin(pObj,true);
if ((pObj.type == 2) || (pObj.type == 3)) {
var lMsg = "Participants are requested to check whether the PAN details are updated/available for self and unregistered participants introduced by them(if any). Registered Participant can check its PAN from Profile menu and for Unregistered Participant from Participant Registration>PAN Registration>Add PAN for unregd. Participant after login. In case PAN is not updated, kindly enter and upload the PAN document from the PAN Registration tab by July 30, 2022.Kindly note that reporting of deals shall not be permitted of Participants (Registered/Unregistered) who have not updated the PAN within the prescribed timelines.";
if ((pObj.rfqAcs) && (((pObj.entityTypeExpired != null) && (pObj.entityTypeExpired)) || (!pObj.showDisclosure))) {
lMsg = "RFQ access has been revoked due to non-confirmation of entity type.";
alert(lMsg,null,function() {
location.href="marketwatch";
})
} else if ((pObj.rfqAcs) && (pObj.entityTypeWarning)) {
lMsg = "Participant is requested ";
if (pObj.warnEndDate) {
lMsg += "
To confirm the entity type from \"Entity Type Disclosure\" tab by Admin login only by "+pObj.warnEndDate+".
";
} else {
lMsg += "
To confirm the entity type from \"Entity Type Disclosure\" tab by Admin login only by (a day before expiry date).
";
}
lMsg += "
In case of any change in entity type, a request to be submitted as per existing process from Participant Amendment->Modify entity type. Post approval of request by exchange, Participant Admin can proceed further to accept entity type disclosure.
";
lMsg += "Failure to confirm the entity type or wrong disclosure will result in revocation of RFQ access.";
alert(lMsg,null,function() {
location.href="participantentitytypeupdate?confirmation=Y";
})
} else if (pObj.panMissing) {
alert(lMsg,null,function() {
location.href="userpandetail";
})
} else if (pObj.panDocMissing) {
lMsg = "PAN document is missing for logged in participant. Kindly upload the same to avoid inconvenience. Click Ok button to update pan document.";
alert(lMsg,null,function() {
location.href="userpandetail";
})
} else {
alert(lMsg,null,function() {
location.href="marketwatch";
})
}
return false;
}
if ((pObj.type == 2) || (pObj.type == 13)) {
if (pObj.gstSubmitted && (pObj.gstSubmitted!='Y')) {
if (!pObj.custodianCode) {
alert("Kindly update GST Details for billing purpose.",null,function() {
location.href="participant?id=0";
})
return false;
}
if (pObj.stateMissing) {
alert("Kindly update your address details for stamp duty purpose.",null,function() {
location.href="participant?id=0";
})
return false;
}
}
}
if (pObj.quesMissing) {
var lMandatory = pObj.resourceGroup === "SECURITY";
var lMessage = "You have not updated your security settings for 2 factor authentication. ";
if (lMandatory)
lMessage += "Please note that 2 factor authentication is mandatory";
else
lMessage += "You can configure 2 factor authentication now";
lMessage += "
';
lMsg += 'Participants are requested to check whether the PAN details are updated/available for self and unregistered participants introduced by them(if any). Registered Participant can check its PAN from Profile menu and for Unregistered Participant from Participant Registration>PAN Registration>Add PAN for unregd. Participant after login. In case PAN is not updated, kindly enter and upload the PAN document from the PAN Registration tab by July 30, 2022. Kindly note that reporting of deals shall not be permitted of Participants (Registered/Unregistered) who have not updated the PAN within the prescribed timelines.';
lMsg += '
';
lMsg += '
';
lMsg += 'Yield Range for the period October 01, 2025 to December 05, 2025 is 5.25% to 14.00%.';
lMsg += '
';
lMsg += '
';
lMsg += 'Yield Range for the period December 06, 2025 to December 31, 2025 is 5.00% to 14.00%.';
lMsg += '
';
lMsg += '
';
lMsg += 'Settlement Timelines for Deals Settled on CBRICS Platform.';
lMsg += 'Download';
lMsg += '
';
lMsg += '
Security Update - Mandatory Password Reset Participants are advised to note that to reinforce security and improve cyber resilience of the system, Exchange shall be implementing enhanced security measures on the application on 07-Nov-2025 EOD. In view of the same, a one-time password change shall need to be undertaken mandatorily by all participants prior to login post 07-Nov-2025 EOD. Access to the application shall be enabled post successful password reset ONLY. For any assistance, please connect on msm@nse.co.in
';
lMsg += '
RFQ participants are requested to note that effective October 06,2025 Exchange shall be accepting digital trade cancellation and modification (TCM) request ONLY.
';
lMsg += '
RFQ participants are requested to refer to the user manual available on the RFQ platform (path: RFQ user guide) for details on digital TCM request.
';
lMsg += '
';
lMsg += '
';
setTimeout(function() {
alert(lMsg,"Important Notification", function() {
fldDomain.focus();
});
}, 500)
$(document).on("click", ".xlx-url1", function() {
var lUrl = $(this).attr("data-href");
window.open(lUrl,"_blank");
});
$(document).on("click", ".xlx-download1", function() {
var lFileName = $(this).attr("data-href1");
downloadFile('upload/LOGINPAGECONTENT/'+lFileName,null);
});
}
function setDisplayMode(pMode) {
$('#contLogin').removeClass('grp1 grp2 grp3');
$('#contLogin').addClass('grp'+pMode);
if (pMode==DISPLAYMODE_LOGIN) {
userDetail={};
$('#divTitle').html("Log in
to your account
");
fieldMandatory([fldPassword,fldNewPassword1,fldNewPassword2], false);
fldDomain.focus();
setCaptcha('Y');
} else if (pMode==DISPLAYMODE_VERIFICATION) {
$('#divTitle').html("Server Verfication");
$('#btnVerify').focus();
var lSecurityTxt = "";
if (userDetail.secretText) lSecurityTxt += "
Verification String:
";
if (userDetail.secretImage) lSecurityTxt += "
Verification Image
";
$('.grp2 #divVerify').html(lSecurityTxt);
} else if (pMode==DISPLAYMODE_PASSWORD) {
$('#btnLogin').removeClass('hidden');
$('#btnLogin').prop('disabled',false);
var lTitle = fldDomain.getValue() + ' ' + fldLogin.getValue();
$('#divTitle').text(lTitle);
// questions div
var lHtml = '';
if (userDetail.questions) {
$.each(userDetail.questions, function(pIndex, pValue){
lHtml+='';
lHtml+='
';
});
lHtml+='';
}
$('#divQuestion').html(lHtml);
$('#divQuestion').removeClass('hidden');
$('#divQuestion #securityAnswer0').focus();
// login btn label
if (formMode==0 || formMode == 4) {
$('#btnLogin').html('null');
} else if (formMode==2) {
$('#btnLogin').html('Recover Password')
} else if (formMode==3) {
$('#btnLogin').html('Clear 2FA Settings');
}
// password fld
fieldMandatory(fldPassword, (formMode==0
|| formMode == 4)
|| (formMode==3));
if ((userDetail.questions==null) && (formMode==0 || formMode == 4)) {
$('#divPassword').removeClass('hidden');
fldPassword.setValue("");
fldNewPassword1.setValue(null);
fldNewPassword2.setValue(null);
fldPassword.focus();
} else {
$('#divPassword').addClass('hidden');
$('#divChangePassword').addClass('hidden');
}
// captcha
if (userDetail.captcha)
setCaptcha('N');
else {
hideCaptcha();
}
}
}
function fieldMandatory(pFld,pFlag) {
if (pFld) {
if ($.isArray(pFld)) {
$.each(pFld,function(pIndex, pValue){
pValue.options.notNull = pFlag;
pValue.options.notBlank = pFlag;
});
} else {
pFld.options.notNull = pFlag;
pFld.options.notBlank = pFlag;
}
}
}
function getUserDetails(pMode) {
if (pMode == 0) {
fieldMandatory([fldPassword,fldNewPassword1,fldNewPassword2], false);
var lErrors = mainForm.check();
if ((lErrors != null) && (lErrors.length > 0)) {
crudLogin.showError();
return;
}
}
var lDomain = fldDomain.getValue().toUpperCase();
var lLogin = fldLogin.getValue().toUpperCase();
if ($('#remember_me').is(':checked')) {
localStorage.setItem('domain',lDomain);
localStorage.setItem('login',lLogin);
} else {
localStorage.removeItem('domain');
localStorage.removeItem('login');
}
var lData = {domain:lDomain,login:lLogin,mode:pMode};
var lUrl = "login/userdetails";
if (isCaptchaShown())
lData.captcha = fldCaptcha.getValue();
$.ajax( {
url: lUrl,
type: "POST",
data: JSON.stringify(lData),
success: function( pObj, pStatus, pXhr) {
if (pMode != 1) {
userDetail=pObj;
formMode = pMode;
} else {
alert("OTP resent successfully.");
}
$('#divChangePassword').addClass('hidden');
setDisplayMode(((userDetail.secretText||userDetail.secretImage)&&(formMode==0))
?DISPLAYMODE_VERIFICATION:DISPLAYMODE_PASSWORD);
},
error: function( pXhr, pStatus, pError ) {
if (isCaptchaShown() || userDetail.captcha)
setCaptcha('Y');
errorHandler(pXhr,pStatus,pError)
},
});
}
function appendAnswers(pData) {
pData.securityAnswers=[];
var lValid = true;
if (userDetail.questions != null) {
$.each(userDetail.questions,function(pIndex,pValue){
var lField$ = $('#securityAnswer'+pIndex);
var lAnswer = lField$.val();
if (lAnswer == '') {
alert("Please enter answer to the question.",null, function(){lField$.focus()});
lValid = false;
return false;
}
pData.securityAnswers.push(lAnswer);
})
}
return lValid;
}
function setChangePassword() {
$('#divQuestion').addClass('hidden');
$('#divChangePassword').removeClass('hidden');
fieldMandatory([fldNewPassword1, fldNewPassword2], true);
$('#btnLogin').html('Change Password');
fldNewPassword1.focus();
//setCaptcha('N');
}
function setCaptcha(pForce) {
var lImgPath = "captcha/"+pForce+"?"+((new Date()).getTime());
var lImg$ = $("#imgCaptcha");
lImg$.one('error',function(){
//lImg$.unbind('error');
lImg$.attr('src','');
alert("Unable to load captcha. Please contact system administrator.");
});
lImg$.attr('src',lImgPath);
fldCaptcha.setValue(null);
fieldMandatory(fldCaptcha, true);
$('#divCaptcha').removeClass('hidden');
}
function hideCaptcha() {
fldCaptcha.setValue(null);
fieldMandatory(fldCaptcha, false);
$('#divCaptcha').addClass('hidden');
}
function isCaptchaShown() {
return !$('#divCaptcha').hasClass('hidden');
}
function encodePassword(pPassword, pUserDetail) {
if (pUserDetail && pUserDetail.passHash) {
if (pUserDetail.salt)
return hashString(hashString(pPassword,pUserDetail.passHash)+pUserDetail.salt, pUserDetail.passHash);
else
return hashString(pPassword, pUserDetail.passHash);
} else if (pUserDetail && pUserDetail.rsa) {
var lPassword = pPassword;
if (pUserDetail.salt)
lPassword += pUserDetail.salt;
return encryptString(lPassword, pUserDetail.rsaPubMod, pUserDetail.rsaPubExp);
}
else
return pPassword;
}
function setPassword(pValue) {
var lDummyPwd = null;
if (tempPwd) {
for (var i=0; i