Password authentication
This commit is contained in:
@@ -278,4 +278,17 @@ body {
|
||||
|
||||
.conformPassword {
|
||||
margin-top: 30px;
|
||||
}
|
||||
.error-warning{
|
||||
font-weight:700 ;
|
||||
color: white;
|
||||
margin-right: 5px;
|
||||
}
|
||||
div#div_ValidationSummary {
|
||||
background: #ce1717;
|
||||
color: white;
|
||||
|
||||
}
|
||||
.p-2{
|
||||
padding: 5px;
|
||||
}
|
||||
@@ -1,12 +1,147 @@
|
||||
function showOtpBox() {
|
||||
document.getElementById('div_ForgotPswd').style.display = 'none';
|
||||
document.getElementById('modal_Otp').style.display = 'block';
|
||||
const serverUrl = 'http://localhost:3088/';
|
||||
let otpid;
|
||||
let sendotp;
|
||||
let unibaseid;
|
||||
async function showOtpBox() {
|
||||
let inputdetails = document.getElementById('txt_PhoneorMail').value;
|
||||
|
||||
let sendnumber = await fetch(serverUrl + 'account/getuserbyphoneormail/'+inputdetails+'/'+inputdetails)
|
||||
let textdata = await sendnumber.json();
|
||||
if(textdata.result != null){
|
||||
unibaseid = textdata.result.unibaseId;
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
var raw = JSON.stringify({
|
||||
"FirstName": "",
|
||||
"LastName": "",
|
||||
"ContactNumber": "",
|
||||
"Email": "",
|
||||
"TenantName": "",
|
||||
"ContactOrEmail": inputdetails,
|
||||
"IsSignup": false,
|
||||
"IsRegisterUser": false,
|
||||
"IsForgotPswd": true,
|
||||
"UnibaseId": unibaseid,
|
||||
"OtpId": 0,
|
||||
"UserOtp": ""
|
||||
});
|
||||
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch(serverUrl + 'account/sendotp', requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(function(result){
|
||||
optid = result;
|
||||
document.getElementById('div_ForgotPswd').style.display = 'none';
|
||||
document.getElementById('modal_Otp').style.display = 'block';
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
}
|
||||
else{
|
||||
let html = '<div class="p-2"><span class="error-warning">Error !</span> Email/Phonenumber does not exist</div>' ;
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
let error = document.getElementById('div_ValidationSummary');
|
||||
error.insertAdjacentHTML('beforeend',html);
|
||||
}
|
||||
}
|
||||
function showPasswordBox() {
|
||||
document.getElementById('modal_Otp').style.display = 'none';
|
||||
document.getElementById('div_ResetPswd').style.display = 'block';
|
||||
|
||||
/*verify otp*/
|
||||
async function showPasswordBox() {
|
||||
let inputdetails = document.getElementById('txt_Code').value;
|
||||
if(inputdetails.length > 0){
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
var raw = JSON.stringify({
|
||||
"FirstName": "",
|
||||
"LastName": "",
|
||||
"ContactNumber": "",
|
||||
"Email": "",
|
||||
"TenantName": "",
|
||||
"ContactOrEmail": "",
|
||||
"IsForgotPswd": false,
|
||||
"IsRegisterUser": false,
|
||||
"IsSignup": true,
|
||||
"UnibaseId": "",
|
||||
"OtpId": optid,
|
||||
"UserOtp": inputdetails
|
||||
});
|
||||
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch(serverUrl + 'account/verifyotp', requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(function(result){
|
||||
let data = JSON.parse(result);
|
||||
if(data.result.contactConfirmed == true){
|
||||
document.getElementById('modal_Otp').style.display = 'none';
|
||||
document.getElementById('div_ResetPswd').style.display = 'block';
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
}else{
|
||||
let html = '<div class="p-2" ><span class="error-warning">Error !</span> Enter Valid OTP</div>' ;
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
let error = document.getElementById('div_ValidationSummary');
|
||||
error.insertAdjacentHTML('beforeend',html);
|
||||
}
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function showSuccessBox() {
|
||||
document.getElementById('div_ResetPswd').style.display = 'none';
|
||||
document.getElementById('div_SuccessMsg').style.display = 'block';
|
||||
}
|
||||
let txt_NewPassword = document.getElementById('txt_NewPassword').value;
|
||||
let txt_ConfirmPassword = document.getElementById('txt_ConfirmPassword').value;
|
||||
if(txt_NewPassword == txt_ConfirmPassword){
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
var raw = JSON.stringify({
|
||||
"Password": txt_NewPassword,
|
||||
"UserName": unibaseid
|
||||
});
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
fetch(serverUrl + 'account/updatepassword', requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(function(result){
|
||||
let updatepassword = JSON.parse(result);
|
||||
let message = updatepassword.message;
|
||||
if(message == 'Password Updated Successfully'){
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
document.getElementById('div_ResetPswd').style.display = 'none';
|
||||
document.getElementById('div_SuccessMsg').style.display = 'block';
|
||||
}
|
||||
}
|
||||
)
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
}else{
|
||||
let html = '<div class="p-2"> <span class="error-warning">Error !</span> Password Does not Match</div>' ;
|
||||
document.getElementById('div_ValidationSummary').innerHTML = "";
|
||||
let error = document.getElementById('div_ValidationSummary');
|
||||
error.insertAdjacentHTML('beforeend',html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user