first commit
This commit is contained in:
Vendored
+347
@@ -0,0 +1,347 @@
|
||||
let SERVERNAME = 'https://app.anwisystems.com';
|
||||
//let SERVERNAME = 'https://anwi.bizgaze.app';
|
||||
//let SERVERNAME = 'http://beta.bizgaze.com';
|
||||
//let SERVERNAME = 'https://qa.anwisystems.com';
|
||||
//let SERVERNAME = 'http://localhost:3088';
|
||||
|
||||
//template
|
||||
//const STAT = '5af6d904ca334734be706b86b8bfe252';
|
||||
|
||||
//live
|
||||
const STAT = '484acd68fe014518b73fa54ad674f0b8';
|
||||
|
||||
const USER_AUTH_OKAY = 'USER_AUTH_OKAY';
|
||||
|
||||
|
||||
function imgServerNameBuild(path){
|
||||
return `https://assets.bizgaze.com/${path}`;
|
||||
}
|
||||
|
||||
|
||||
async function getStatAPIService(url,data={}){
|
||||
let config = {
|
||||
url,
|
||||
method:'get',
|
||||
data:data,
|
||||
headers: {
|
||||
'Authorization': `stat ${STAT}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
async function getAPIService(url,data={}){
|
||||
|
||||
const config = {
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method: "get",
|
||||
};
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
async function postAPIService(url,data={}){
|
||||
let config = {
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'post',
|
||||
data:data,
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
async function postStatAPIService(url,data={}){
|
||||
let config = {
|
||||
url,
|
||||
method:'post',
|
||||
data:data,
|
||||
headers: {
|
||||
'Authorization': `stat ${STAT}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function postAPIServiceLocal(url,data={}){
|
||||
let config = {
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'post',
|
||||
data:JSON.stringify(data ),
|
||||
headers: {
|
||||
'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
async function getAPIServiceLocal(url){
|
||||
let config = {
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'get',
|
||||
|
||||
headers: {
|
||||
'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
class API_SERVICE_CLASS{
|
||||
baseURL = '';
|
||||
token='';
|
||||
statToken=STAT;
|
||||
Instance = null;
|
||||
|
||||
constructor(baseurl){
|
||||
this.Instance = this;
|
||||
this.baseURL = baseurl;
|
||||
|
||||
this.getService = this.getService.bind(this);
|
||||
this.postService = this.postService.bind(this);
|
||||
this.justGetAPIService =this.justGetAPIService.bind(this);
|
||||
this.justPostAPIService = this.justPostAPIService.bind(this);
|
||||
|
||||
}
|
||||
|
||||
getService(url,isStat = false){
|
||||
return this.baseService(this.buildURL(url),'get',isStat);
|
||||
}
|
||||
|
||||
postService(url,data,isStat = false){
|
||||
return this.baseService(this.buildURL(url),'post',isStat,data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async baseService(url,method,isStat,data){
|
||||
let isPost = method == 'get' ? false : true;
|
||||
const cookieData = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
if(!isStat){
|
||||
if(!cookieData) return window.location.href = "/"
|
||||
}
|
||||
let token = isStat ?`stat ${this.statToken}` : `Basic ${cookieData.token}`;
|
||||
this.token = token;
|
||||
let successResFun = this.buildSuccessResponse;
|
||||
let failureResFun = this.buildFailureResponse;
|
||||
let config = {
|
||||
url,
|
||||
method,
|
||||
headers:{
|
||||
'Authorization': token,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
if(isPost){
|
||||
config['data'] = data;
|
||||
}
|
||||
|
||||
try {
|
||||
let response
|
||||
try {
|
||||
response = await axios(config);
|
||||
if(response.data === true || response.data === false){
|
||||
return successResFun(response.data)
|
||||
}
|
||||
if(response.data.code == '417'){
|
||||
// window.location.href = '/index.html'
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
if(response.data.code != '0'){
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
|
||||
if(response.data.errors?.length){
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
return successResFun(response.data)
|
||||
|
||||
} catch (error) {
|
||||
return failureResFun(error)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return failureResFun(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildURL(url){
|
||||
return `${this.baseURL}/${url}`;
|
||||
}
|
||||
|
||||
buildSuccessResponse(response){
|
||||
return {
|
||||
isError : false,
|
||||
errorMsg : null,
|
||||
response:response,
|
||||
}
|
||||
}
|
||||
|
||||
buildFailureResponse(error){
|
||||
return {
|
||||
isError : true,
|
||||
errorMsg : error,
|
||||
response:null,
|
||||
}
|
||||
}
|
||||
|
||||
async justAPI_BaseService(){
|
||||
let isPost = method == 'get' ? false : true;
|
||||
|
||||
|
||||
let successResFun = this.buildSuccessResponse;
|
||||
let failureResFun = this.buildFailureResponse;
|
||||
let config = {
|
||||
url,
|
||||
method,
|
||||
headers:{
|
||||
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
if(isPost){
|
||||
config['data'] = data;
|
||||
}
|
||||
|
||||
try {
|
||||
let response
|
||||
try {
|
||||
response = await axios(config);
|
||||
if(response.data.code == '417'){
|
||||
// window.location.href = '/index.html'
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
if(response.data.code != '0'){
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
return successResFun(response.data)
|
||||
|
||||
} catch (error) {
|
||||
return failureResFun(error)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return failureResFun(error)
|
||||
}
|
||||
}
|
||||
|
||||
justGetAPIService(url){
|
||||
return this.justAPI_BaseService('get',url)
|
||||
}
|
||||
justPostAPIService(url){
|
||||
return this.justAPI_BaseService('post',url)
|
||||
}
|
||||
|
||||
|
||||
isValid(){
|
||||
const cookieData = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
if(!cookieData){
|
||||
return justGetAPIService('/Account/Session/Validate')
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const API_SERVICES = new API_SERVICE_CLASS(SERVERNAME);
|
||||
|
||||
const API_SERVICES_ACTIONS = {
|
||||
postAPIService:API_SERVICES.postService,
|
||||
getAPIService:API_SERVICES.getService
|
||||
}
|
||||
|
||||
|
||||
// cookie helper
|
||||
const AUTH = 'AUTH'
|
||||
|
||||
class COOKIE_HELPER_CLASS{
|
||||
constructor(){
|
||||
this.getCookie = this.getCookie.bind(this);
|
||||
}
|
||||
getCookie(){
|
||||
let cookieVal = Cookies.get(AUTH);
|
||||
if(!cookieVal){
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(cookieVal)
|
||||
};
|
||||
setCookie(value){
|
||||
debugger;
|
||||
return Cookies.set(AUTH,value)
|
||||
};
|
||||
|
||||
removeCookie(token){
|
||||
Cookies.remove(token)
|
||||
}
|
||||
|
||||
|
||||
async validateToken(){
|
||||
return await API_SERVICES_ACTIONS.getAPIService(`Account/Session/Validate`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const COOKIE_HELPER = new COOKIE_HELPER_CLASS();
|
||||
const COOKIE_HELPER_ACTIONS ={
|
||||
getCookie : COOKIE_HELPER.getCookie,
|
||||
setCookie :COOKIE_HELPER.setCookie,
|
||||
removeAuthCookie:COOKIE_HELPER.removeCookie.bind(null,AUTH)
|
||||
}
|
||||
|
||||
|
||||
function setCookieManual(token){
|
||||
Cookies.set(AUTH,{
|
||||
token,
|
||||
userId:null
|
||||
})
|
||||
}
|
||||
|
||||
async function checkValidAuth(cb,redirect=undefined){
|
||||
debugger;
|
||||
|
||||
document.querySelector('auth-loader').show();
|
||||
const res = await COOKIE_HELPER.validateToken();
|
||||
if(!res.response){
|
||||
if(redirect){
|
||||
window.location.href =redirect;
|
||||
document.querySelector('auth-loader').hide();
|
||||
return;
|
||||
}
|
||||
window.location.href = '/';
|
||||
document.querySelector('auth-loader').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(()=>{
|
||||
document.querySelector('auth-loader').hide();
|
||||
cb();
|
||||
},300);
|
||||
}
|
||||
|
||||
|
||||
// setCookieManual('6eb70fee-35ef-4ca2-95cd-01ebdd616eb1');
|
||||
Vendored
+686
@@ -0,0 +1,686 @@
|
||||
|
||||
|
||||
let AUTH_LOGIN_APIS_URL = {
|
||||
isUser(user) {
|
||||
return `account/getuserbyphoneormail/${user}/${user}`;
|
||||
},
|
||||
login() {
|
||||
return `bizgaze/crm/webapi/crmuserlogin`
|
||||
},
|
||||
signUp() {
|
||||
return `bizgaze/crm/webapi/registercrmuser`;
|
||||
},
|
||||
resendOTP() {
|
||||
return `bizgaze/crm/webapi/ReSendOtp`;
|
||||
},
|
||||
sendOTP() {
|
||||
return `account/sendotp`;
|
||||
},
|
||||
updatePassword() {
|
||||
return `account/UpdatePassword`;
|
||||
}
|
||||
}
|
||||
|
||||
initLogin();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function initLogin() {
|
||||
|
||||
let userDetails = {
|
||||
otpid: null,
|
||||
email: null,
|
||||
password: null,
|
||||
unibaseid: null
|
||||
}
|
||||
let backotp = null;
|
||||
let backOptions = {
|
||||
forgotPassword:'forgotPassword',
|
||||
EmailnotV:'EmailnotV',
|
||||
signUp:'signUp'
|
||||
}
|
||||
let authloginLoadingBtnAction = {
|
||||
addLoading() {
|
||||
$('.authloginLoading').addClass('d-none');
|
||||
$('.authloginLoadingBtn').removeClass('d-none');
|
||||
},
|
||||
removeLoading() {
|
||||
$('.authloginLoading').removeClass('d-none');
|
||||
$('.authloginLoadingBtn').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let otpLoadingAction = {
|
||||
addLoadingOTP() {
|
||||
$('.otploading').removeClass('d-none');
|
||||
$('.otploadingtext').addClass('d-none');
|
||||
},
|
||||
removeLoadingOTP() {
|
||||
$('.otploading').addClass('d-none');
|
||||
$('.otploadingtext').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let formErrorAction = {
|
||||
addError(message) {
|
||||
$('.error_msg').removeClass('d-none');
|
||||
$('.error_msg_res').html(message);
|
||||
},
|
||||
removeClass() {
|
||||
$('.error_msg').addClass('d-none');
|
||||
$('.error_msg_res').html('');
|
||||
}
|
||||
}
|
||||
function init() {
|
||||
const logoauth = $('.logoauth');
|
||||
logoauth.removeClass('d-none');
|
||||
loginUI();
|
||||
//updatePasswordUI();
|
||||
//OTP_UI()
|
||||
}
|
||||
|
||||
|
||||
function checkPassword(value){
|
||||
const specailHelper = containsSpecialCharsHelper(value);
|
||||
const isUpperCase = isUpperCaseHelper(value);
|
||||
const isLowerCase = isLowerCaseHelper(value);
|
||||
const isNumber = isNumberContainsHelper(value);
|
||||
const len = value.length>=8;
|
||||
|
||||
return specailHelper && isUpperCase && isLowerCase && isNumber && len;
|
||||
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
function updatePasswordUI() {
|
||||
formErrorAction.removeClass();
|
||||
let html = ` <form class="row g-3 needs-validation" novalidate> <div class="form-floating position-relative py-0"> <input required type="password" class="form-control shadow-none h-50p passwordvalidui" id="updatepassword" placeholder="Enter Your Password" autocomplete="off"> <span class="position-absolute eyePassword" style=" top: 50%; right: 3%; transform: translateY(-50%);"> <i class="text-dark fa fa-eye-slash"></i> </span> <label for="updatepassword">Password </label> <div class="invalid-feedback"> Please enter password. </div> <div class="pswd_info" style="display: none;z-index: 1;"> <p>Password must contain:</p> <ul> <li id="chck_capital" class="invalid">At least <strong>one capital letter</strong> </li> <li id="chck_small" class="invalid">At least <strong>one lowercase letter</strong> </li> <li id="chck_special" class="invalid">At least <strong>one special letter</strong> </li> <li id="chck_number" class="invalid">At least <strong>one number</strong> </li> <li id="chck_length" class="invalid">At least <strong>8 characters</strong> </li> </ul> </div> </div> <div class="form-floating position-relative py-0"> <input required type="password" class="form-control shadow-none h-50p passwordvalidui" id="updateconfirmpassword" placeholder="Enter Your Password" autocomplete="off"> <span class="position-absolute eyePassword" style=" top: 50%; right: 3%; transform: translateY(-50%);"> <i class="text-dark fa fa-eye-slash"></i> </span> <label for="updateconfirmpassword">Password </label> <div class="invalid-feedback"> Please enter password. </div> <div class="pswd_info" style="display: none;z-index: 1;"> <p>Password must contain:</p> <ul> <li id="chck_capital" class="invalid">At least <strong>one capital letter</strong> </li> <li id="chck_small" class="invalid">At least <strong>one lowercase letter</strong> </li> <li id="chck_special" class="invalid">At least <strong>one special letter</strong> </li> <li id="chck_number" class="invalid">At least <strong>one number</strong> </li> <li id="chck_length" class="invalid">At least <strong>8 characters</strong> </li> </ul> </div> </div> <div class="col-12 pt-3 mt-0 px-0"> <button class="btn bg-gradient-anwi text-white w-100 cursor-pointer h-50p btnupdatepassword" type="submit"> <div class="spinner-border authloginLoadingBtn d-none" role="status"> <span class="visually-hidden">Loading...</span> </div> <span class="authloginLoading">Update Password</span> </button> </div> </form>`;
|
||||
|
||||
$('.authContainerUI').html(html);
|
||||
updatepasswordEvents();
|
||||
}
|
||||
|
||||
function updatepasswordEvents() {
|
||||
|
||||
$('.needs-validation').off('submit');
|
||||
loadPasswordListener();
|
||||
$('.needs-validation').on('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
let ele = document.querySelector('.needs-validation')
|
||||
if (!ele.checkValidity()) {
|
||||
ele.classList.add('was-validated')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let newPassword = $('#updatepassword').val();
|
||||
let passwordConfirm = $('#updateconfirmpassword').val();
|
||||
|
||||
|
||||
if (newPassword != passwordConfirm) {
|
||||
formErrorAction.addError("Password doesn't match");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!checkPassword(newPassword)){
|
||||
formErrorAction.addError("Password doesn't match");
|
||||
return;
|
||||
}
|
||||
|
||||
const forgotpassPayload = {
|
||||
username: userDetails.unibaseid,
|
||||
password: passwordConfirm,
|
||||
};
|
||||
|
||||
const res = await postAPIService(AUTH_LOGIN_APIS_URL.updatePassword(), forgotpassPayload);
|
||||
|
||||
|
||||
|
||||
if (res.data.message == 'Password Updated Successfully') {
|
||||
loginUI();
|
||||
toasterHelper("success", "Password updated successfull");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function loadPasswordListener(){
|
||||
|
||||
$('.passwordvalidui').off().on('keyup',function (e){
|
||||
debugger;
|
||||
$(this).parent().find('.pswd_info').css('display','block');
|
||||
let value = $(this).val();
|
||||
|
||||
const specailHelper = containsSpecialCharsHelper(value);
|
||||
const isUpperCase = isUpperCaseHelper(value);
|
||||
const isLowerCase = isLowerCaseHelper(value);
|
||||
const isNumber = isNumberContainsHelper(value);
|
||||
|
||||
|
||||
if(isLowerCase){
|
||||
$(this).parent().find('#chck_small').addClass('text-decoration-line-through');
|
||||
}else{
|
||||
$(this).parent().find('#chck_small').removeClass('text-decoration-line-through');
|
||||
}
|
||||
|
||||
if(specailHelper){
|
||||
$(this).parent().find('#chck_special').addClass('text-decoration-line-through');
|
||||
}else{
|
||||
$(this).parent().find('#chck_special').removeClass('text-decoration-line-through');
|
||||
}
|
||||
|
||||
if(isUpperCase){
|
||||
$(this).parent().find('#chck_capital').addClass('text-decoration-line-through');
|
||||
}else{
|
||||
$(this).parent().find('#chck_capital').removeClass('text-decoration-line-through');
|
||||
}
|
||||
|
||||
if(value.length>=8){
|
||||
$(this).parent().find('#chck_length').addClass('text-decoration-line-through');
|
||||
}else{
|
||||
$(this).parent().find('#chck_length').removeClass('text-decoration-line-through');
|
||||
}
|
||||
|
||||
if(isNumber){
|
||||
$(this).parent().find('#chck_number').addClass('text-decoration-line-through');
|
||||
}else{
|
||||
$(this).parent().find('#chck_number').removeClass('text-decoration-line-through');
|
||||
}
|
||||
|
||||
|
||||
}).blur(function (e){
|
||||
$(this).parent().find('.pswd_info').css('display','none');
|
||||
})
|
||||
|
||||
$('.eyePassword').off();
|
||||
$('.eyePassword').click(function (e){
|
||||
e.stopPropagation();
|
||||
let eyeOpen = '<i class="text-dark fa fa-eye"></i>';
|
||||
let eyeClose = '<i class="text-dark fa fa-eye-slash"></i>';
|
||||
let isClose = $(this).find(`.fa-eye-slash`).length;
|
||||
|
||||
if(isClose){
|
||||
$(this).html(eyeOpen);
|
||||
$(this).parent().find('.passwordvalidui').attr('type','text');
|
||||
}else{
|
||||
$(this).html(eyeClose);
|
||||
$(this).parent().find('.passwordvalidui').attr('type','password');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function resendOTP() {
|
||||
otpLoadingAction.addLoadingOTP();
|
||||
let payload = {
|
||||
"FirstName": "",
|
||||
"LastName": "",
|
||||
"ContactNumber": "",
|
||||
"Email": "",
|
||||
"TenantName": "",
|
||||
"ContactOrEmail": userDetails.email,
|
||||
"IsSignup": false,
|
||||
"IsRegisterUser": true,
|
||||
"IsForgotPswd": false,
|
||||
"UnibaseId": userDetails.unibaseid,
|
||||
"OtpId": parseInt(userDetails.otpid),
|
||||
"UserOtp": ""
|
||||
}
|
||||
let res = await postAPIService(AUTH_LOGIN_APIS_URL.resendOTP(), payload);
|
||||
res = res.data;
|
||||
if (res.code != '0' || res.message != 'OTP resent successfully') {
|
||||
return;
|
||||
}
|
||||
userDetails = { ...userDetails, otpid: res.result };
|
||||
otpLoadingAction.removeLoadingOTP();
|
||||
}
|
||||
|
||||
function loadForpasswordsEvents() {
|
||||
$('.needs-validation').off('submit');
|
||||
$('.needs-validation').on('submit', async (event) => {
|
||||
event.preventDefault()
|
||||
let ele = document.querySelector('.needs-validation')
|
||||
if (!ele.checkValidity()) {
|
||||
ele.classList.add('was-validated')
|
||||
return;
|
||||
}
|
||||
const email = $('#forgotpassword').val();
|
||||
|
||||
await sendOTPService(email,1,backOptions.forgotPassword);
|
||||
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('.btnForgotback').click(function (e) {
|
||||
loginUI();
|
||||
})
|
||||
}
|
||||
|
||||
function forgotPasswordUIEmail() {
|
||||
formErrorAction.removeClass();
|
||||
let html = `<div> <div class="d-flex justify-content-between border-bottom pb-1"><span>Forgot Password?</span><span class="btnForgotback cursor-pointer"><i class="fa-solid fa-arrow-left"></i></span></div> <div class="py-3">Enter the email associated with your account and we'll send an email with instructions to reset your password.</div> <div> <form class="row g-3 needs-validation" novalidate> <div class="pb-3 form-floating py-0"> <input required type="email" class="form-control shadow-none h-50p" id="forgotpassword" placeholder="Enter Your Email" autocomplete="off"> <label for="forgotpassword">Email address</label> <div class="invalid-feedback"> Please enter email. </div> </div> <div class="col-12 mt-0 px-0"> <button class="btn h-50p forgotpasswordbtn bg-gradient-anwi text-white w-100 cursor-pointer" type="submit"> <div class="spinner-border authloginLoadingBtn d-none" role="status"> <span class="visually-hidden">Loading...</span> </div> <span class="authloginLoading ">Password Reset</span> </button> </div> </form> </div></div>`;
|
||||
$('.authContainerUI').html(html);
|
||||
loadForpasswordsEvents();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function loginEvents() {
|
||||
|
||||
|
||||
// submit event
|
||||
$('.needs-validation').off('submit');
|
||||
$('.needs-validation').on('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
let ele = document.querySelector('.needs-validation')
|
||||
if (!ele.checkValidity()) {
|
||||
ele.classList.add('was-validated')
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const email = $('#User_Email').val();
|
||||
|
||||
const isUserURL = AUTH_LOGIN_APIS_URL.isUser(email);
|
||||
authloginLoadingBtnAction.addLoading();
|
||||
const user = await getAPIService(isUserURL);
|
||||
const isUser = user.data.result === null && user.data.message === `Email/Phonenumber doesn't exist`;
|
||||
|
||||
if (!isUser) {
|
||||
loginUser();
|
||||
} else {
|
||||
signUpUser();
|
||||
}
|
||||
});
|
||||
|
||||
// forgot password
|
||||
$('.forgotpasswordBtn').click(function (e) {
|
||||
forgotPasswordUIEmail();
|
||||
});
|
||||
loadPasswordListener();
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function loginUserService(email, passord) {
|
||||
const loginPayload = {
|
||||
username: email,
|
||||
Password: passord,
|
||||
UnibaseId: "",
|
||||
RememberMe: false,
|
||||
};
|
||||
|
||||
let res = await postAPIService(AUTH_LOGIN_APIS_URL.login(),
|
||||
loginPayload
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
async function loginUser() {
|
||||
formErrorAction.removeClass();
|
||||
let userEmail = $("#User_Email").val();
|
||||
let userPassword = $("#User_password").val();
|
||||
|
||||
|
||||
let res = await loginUserService(userEmail, userPassword);
|
||||
res = res.data;
|
||||
|
||||
let isError = res.code != '0';
|
||||
|
||||
|
||||
userDetails['email'] = userEmail;
|
||||
userDetails['password'] = userPassword;
|
||||
debugger;
|
||||
if (isError) {
|
||||
if (res.message === 'Email is not verified') {
|
||||
formErrorAction.addError(`<span><span>${res.message}</span> <span class="validemail cursor-pointer"><u>Valid here</u></span></span>`);
|
||||
|
||||
$('.validemail').off('click')
|
||||
$('.validemail').click(async function (e) {
|
||||
await sendOTPService(userEmail,2,backOptions.EmailnotV);
|
||||
formErrorAction.removeClass();
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
|
||||
});
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
formErrorAction.addError(`${res.message}`);
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.result.sessionId,
|
||||
userid: res.result.userId,
|
||||
...res.result
|
||||
});
|
||||
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
localStorage.setItem(USER_AUTH_OKAY,2);
|
||||
window.location.href = '/';
|
||||
//authloginLoadingBtnAction.removeLoading();
|
||||
}
|
||||
|
||||
async function sendOTPService(userEmail,num=0,option) {
|
||||
const isUserURL = AUTH_LOGIN_APIS_URL.isUser(userEmail);
|
||||
authloginLoadingBtnAction.addLoading();
|
||||
const user = await getAPIService(isUserURL);
|
||||
const isUser = user.data.result === null || user.data.message === `Email/Phonenumber doesn't exist`;
|
||||
if (isUser) {
|
||||
formErrorAction.addError(user.data.message);
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
const forgotpassPayload = {
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
contactnumber: "",
|
||||
email: "",
|
||||
tenantname: "",
|
||||
contactoremail: user.data.result.email,
|
||||
IsSignup: false,
|
||||
IsRegisterUser: false,
|
||||
IsForgotPswd: true,
|
||||
UnibaseId: user.data.result.userName,
|
||||
OtpId: 0,
|
||||
UserOtp: "",
|
||||
};
|
||||
|
||||
const forgetpassRes = await postAPIService(
|
||||
AUTH_LOGIN_APIS_URL.sendOTP(),
|
||||
forgotpassPayload
|
||||
);
|
||||
|
||||
userDetails.email = userEmail;
|
||||
userDetails.otpid = forgetpassRes.data;
|
||||
userDetails.unibaseid = user.data.result.userName;
|
||||
backotp = option
|
||||
OTP_UI(num);
|
||||
|
||||
}
|
||||
|
||||
async function signUpUser() {
|
||||
formErrorAction.removeClass();
|
||||
let userEmail = $("#User_Email").val();
|
||||
let userPassword = $("#User_password").val();
|
||||
let checkPasswordValue = checkPassword(userPassword);
|
||||
if(!checkPasswordValue){
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
formErrorAction.addError('Password must contain one specail letter ,number,small letter, uppercase letter and 8 letters');
|
||||
return;
|
||||
}
|
||||
const userRegistratioNPayload = {
|
||||
organizationtypeid: "2",
|
||||
organizationid: "0",
|
||||
contactid: "0",
|
||||
userid: "0",
|
||||
username: "0",
|
||||
users_phonenumber: "0",
|
||||
password: userPassword,
|
||||
users_emailaddress: "0",
|
||||
emailaddress: userEmail,
|
||||
contactname: userEmail.split('@')[0],
|
||||
phonenumber: "0",
|
||||
branchid: "0",
|
||||
tenantname: "Anwi Systems",
|
||||
rolename: "Customer Admin",
|
||||
currencyid: "0",
|
||||
customerformuniqueid: "Bizgaze_Platform_Crm_RegisterCRMUser",
|
||||
};
|
||||
|
||||
let res = await postAPIService(
|
||||
AUTH_LOGIN_APIS_URL.signUp(),
|
||||
userRegistratioNPayload
|
||||
);
|
||||
|
||||
res = res.data;
|
||||
if (res.code != '0') {
|
||||
formErrorAction.addError(res.message);
|
||||
authloginLoadingBtnAction.removeLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
res = res.result;
|
||||
|
||||
userDetails['otpid'] = res.OtpId;
|
||||
userDetails['email'] = userEmail;
|
||||
userDetails['password'] = userPassword;
|
||||
userDetails['unibaseid'] = res.UnibaseId;
|
||||
backotp = backOptions.signUp
|
||||
OTP_UI();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loginUI() {
|
||||
formErrorAction.removeClass();
|
||||
let html = `<div class="text-center pb-4">
|
||||
<span class="font-weight-600">Login</span> / <span class="font-weight-600">Signup</span>
|
||||
</div>
|
||||
<form class="row g-3 needs-validation" novalidate>
|
||||
<div class="form-floating py-0">
|
||||
<input required type="email" class="form-control shadow-none h-50p" id="User_Email" placeholder="Enter Your Email" autocomplete="off">
|
||||
<label for="User_Email">Email address</label>
|
||||
<div class="invalid-feedback"> Please enter email. </div>
|
||||
</div>
|
||||
<div class="form-floating position-relative py-0">
|
||||
<input required type="password" class="form-control shadow-none h-50p passwordvalidui" id="User_password" placeholder="Enter Your Password" autocomplete="off">
|
||||
<span class="position-absolute eyePassword" style=" top: 50%; right: 3%; transform: translateY(-50%);">
|
||||
<i class="text-dark fa fa-eye-slash"></i>
|
||||
</span>
|
||||
<label for="User_password">Password </label>
|
||||
<div class="invalid-feedback"> Please enter password. </div>
|
||||
<div class="pswd_info" style="display: none;z-index: 1;">
|
||||
<p>Password must contain:</p>
|
||||
<ul>
|
||||
<li id="chck_capital" class="invalid">At least <strong>one capital letter</strong>
|
||||
</li>
|
||||
<li id="chck_small" class="invalid">At least <strong>one lowercase letter</strong>
|
||||
</li>
|
||||
<li id="chck_special" class="invalid">At least <strong>one special letter</strong>
|
||||
</li>
|
||||
<li id="chck_number" class="invalid">At least <strong>one number</strong>
|
||||
</li>
|
||||
<li id="chck_length" class="invalid">At least <strong>8 characters</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fs-7 my-2 satoshi_font text-center"> By continuing, I agree to the Terms of Use & Privacy Policy </div>
|
||||
<div class="col-12 mt-0 px-0">
|
||||
<button class="btn bg-gradient-anwi text-white w-100 cursor-pointer h-50p" type="submit">
|
||||
<div class="spinner-border authloginLoadingBtn d-none" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<span class="authloginLoading h-50p">Continue</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="pt-3 text-center">
|
||||
<span class="forgotpasswordBtn cursor-pointer">Forgot password?</span>
|
||||
</div>
|
||||
`;
|
||||
$('.authContainerUI').html(html);
|
||||
|
||||
loginEvents();
|
||||
}
|
||||
|
||||
function OTP_UI(forgot = 0) {
|
||||
formErrorAction.removeClass();
|
||||
let html = `<div class="d-flex justify-content-between border-bottom pb-1">
|
||||
<span></span>
|
||||
<span class="btnForgotback">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</span>
|
||||
</div> <div class="otp-validation"> <div class="otp-input-group mt-3"> <div> <h4 class="text-center">Enter OTP</h4> <div class="text-center">We have send OTP to your email </div> <p class="user_email text-center"></p> <div class="otp-sent-email fw-600 text-center"></div> </div> <div class="d-flex my-4"> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="1" autocomplete="off"> </div> </div> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="2" autocomplete="off"> </div> </div> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="3" autocomplete="off"> </div> </div> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="4" autocomplete="off"> </div> </div> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="5" autocomplete="off"> </div> </div> <div class="col"> <div class="form-group"> <input type="text" class="press form-control" name="code" maxlength="1" tabindex="6" autocomplete="off"> </div> </div> </div> <div> <div class="btn bg-gradient-anwi w-100 loader-btn" style="display: none;"> <span class="loader"></span> </div> <a href="#" class=" h-50p d-flex align-items-center justify-content-center bg-gradient-anwi btn fw-500 text-white w-100" id="email_validate_proceed" type="submit"><div class="spinner-border otploading d-none" role="status">
|
||||
</div><span class="otploadingtext">Verfiy OTP</span></a> </div> <div class="resendOTP cursor-pointer text-center pt-4 ">Resend OTP</div> </div></div>`;
|
||||
$('.authContainerUI').html(html);
|
||||
loadOTPEvents(forgot);
|
||||
}
|
||||
|
||||
async function validOTP(email, id, otp) {
|
||||
const validateForgotpass = {
|
||||
email: email,
|
||||
otpid: id,
|
||||
userotp: otp,
|
||||
};
|
||||
|
||||
const res = await postAPIService(
|
||||
`hyperfusion/validateotp`,
|
||||
validateForgotpass
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function loadOTPEvents(forgot) {
|
||||
|
||||
|
||||
$('.resendOTP').click(function (e) {
|
||||
resendOTP();
|
||||
})
|
||||
|
||||
|
||||
$('.btnForgotback').off().click(function(e){
|
||||
debugger;
|
||||
if(backotp === backOptions.forgotPassword){
|
||||
forgotPasswordUIEmail();
|
||||
}else if(backotp === backOptions.EmailnotV){
|
||||
loginUI();
|
||||
}else if(backotp === backOptions.signUp){
|
||||
loginUI();
|
||||
}
|
||||
});
|
||||
|
||||
$("#email_validate_proceed").click(async function () {
|
||||
debugger;
|
||||
otpLoadingAction.addLoadingOTP();
|
||||
let userotp = '';
|
||||
$(".otp-validation .otp-input-group input").each(function () {
|
||||
let presVal = $(this).val();
|
||||
userotp += presVal;
|
||||
});
|
||||
|
||||
if (userotp.length == 6) {
|
||||
// const validateForgotpass = {
|
||||
// email: userDetails.email,
|
||||
// otpid: userDetails.otpid,
|
||||
// userotp: userotp,
|
||||
// };
|
||||
$('#email_validate_proceed').hide()
|
||||
$(".loader-btn").show();
|
||||
const validate_email_resopt = await validOTP(userDetails.email, userDetails.otpid, userotp);
|
||||
|
||||
$(".loader-btn").hide();
|
||||
$('#email_validate_proceed').show()
|
||||
const Resotp = validate_email_resopt.data.result;
|
||||
if (Resotp == "Otp verified successfully") {
|
||||
if (forgot == 1) {
|
||||
updatePasswordUI();
|
||||
return;
|
||||
} else if (forgot == 2) {
|
||||
loginUI();
|
||||
toasterHelper("success", "Email has been verified");
|
||||
return;
|
||||
}
|
||||
const res = await loginUserService(userDetails.email, userDetails.password);
|
||||
|
||||
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.data.result.sessionId,
|
||||
userid: res.data.result.userId,
|
||||
...res.data.result
|
||||
});
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
localStorage.setItem(USER_AUTH_OKAY,1);
|
||||
window.location.href = '/';
|
||||
otpLoadingAction.removeLoadingOTP();
|
||||
} else {
|
||||
// toasterOpts()
|
||||
// Command: toastr["error"]("Please enter Valid OTP");
|
||||
otpLoadingAction.removeLoadingOTP();
|
||||
formErrorAction.addError("Please enter Valid OTP")
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
otpLoadingAction.removeLoadingOTP();
|
||||
formErrorAction.addError("Please enter Valid OTP")
|
||||
}
|
||||
});
|
||||
|
||||
$(".otp-validation .otp-input-group").on("paste", function (p) {
|
||||
let data = p.originalEvent.clipboardData.getData("text");
|
||||
let dataLength = data.length;
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let input = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' + (i + 1) + '"]'
|
||||
);
|
||||
input.val(data.charAt(i));
|
||||
if (input.val().length >= input.attr("maxlength")) {
|
||||
let nextInput = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
(i + 2) +
|
||||
'"]'
|
||||
);
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.preventDefault();
|
||||
});
|
||||
|
||||
$('.otp-validation .otp-input-group input[type="text"]').on(
|
||||
"keyup",
|
||||
function (e) {
|
||||
if ($(this).val().length >= $(this).attr("maxlength")) {
|
||||
if (e.keyCode !== 9 && e.keyCode !== 16) {
|
||||
let tabIndex = parseInt($(this).attr("tabindex")) + 1;
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
$(this).attr("tabindex") +
|
||||
'"]'
|
||||
).val($(this).val());
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
tabIndex +
|
||||
'"]'
|
||||
).focus();
|
||||
}
|
||||
} else {
|
||||
if (e.keyCode === 8) {
|
||||
let tabIndex = parseInt($(this).attr("tabindex")) - 1;
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
tabIndex +
|
||||
'"]'
|
||||
).focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Vendored
+375
@@ -0,0 +1,375 @@
|
||||
function initLogin() {
|
||||
let reg_name, reg_email, reg_number, reg_pwd, reg_otp_email;
|
||||
let loginForm = $("#login_form");
|
||||
let registerForm = $("#register_form");
|
||||
|
||||
// document.querySelector('#register_form .otp-input-group input.press').addEventListener("paste", function (p) {
|
||||
// var data = p.clipboardData.getData('text');
|
||||
// var dataLength = data.length;
|
||||
|
||||
// for (var i = 0; i < dataLength; i++) {
|
||||
// var input = document.querySelector("#register_form .otp-input-group input[tabindex='" + (i + 1) + "']");
|
||||
// input.value = data.charAt(i);
|
||||
// if (input.value.length >= input.maxLength) {
|
||||
// var nextInput = document.querySelector("#register_form .otp-input-group input[tabindex='" + (i + 2) + "']");
|
||||
// if (nextInput) {
|
||||
// nextInput.focus();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// p.preventDefault();
|
||||
// });
|
||||
// document.querySelectorAll('#register_form .otp-input-group input[type="text"]').forEach(function (input) {
|
||||
// input.addEventListener('keyup', function (e) {
|
||||
// if (this.value.length >= this.maxLength) {
|
||||
// if (e.keyCode !== 9 && e.keyCode !== 16) {
|
||||
// var tabIndex = this.tabIndex + 1;
|
||||
// document.querySelector("#register_form .otp-input-group input[tabindex='" + this.tabIndex + "']").value = this.value;
|
||||
// document.querySelector("#register_form .otp-input-group input[tabindex='" + tabIndex + "']").focus();
|
||||
// }
|
||||
// } else {
|
||||
// if (e.keyCode === 8) {
|
||||
// var tabIndex = this.tabIndex - 1;
|
||||
// document.querySelector("#register_form .otp-input-group input[tabindex='" + tabIndex + "']").focus();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$('#register_form .otp-input-group input.press').on('paste', function (p) {
|
||||
var data = p.originalEvent.clipboardData.getData('text');
|
||||
var dataLength = data.length;
|
||||
|
||||
for (var i = 0; i < dataLength; i++) {
|
||||
var input = $('#register_form .otp-input-group input[tabindex="' + (i + 1) + '"]');
|
||||
input.val(data.charAt(i));
|
||||
if (input.val().length >= input.attr('maxlength')) {
|
||||
var nextInput = $('#register_form .otp-input-group input[tabindex="' + (i + 2) + '"]');
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.preventDefault();
|
||||
});
|
||||
|
||||
$('#register_form .otp-input-group input[type="text"]').on('keyup', function (e) {
|
||||
if ($(this).val().length >= $(this).attr('maxlength')) {
|
||||
if (e.keyCode !== 9 && e.keyCode !== 16) {
|
||||
var tabIndex = parseInt($(this).attr('tabindex')) + 1;
|
||||
$('#register_form .otp-input-group input[tabindex="' + $(this).attr('tabindex') + '"]').val($(this).val());
|
||||
$('#register_form .otp-input-group input[tabindex="' + tabIndex + '"]').focus();
|
||||
}
|
||||
} else {
|
||||
if (e.keyCode === 8) {
|
||||
var tabIndex = parseInt($(this).attr('tabindex')) - 1;
|
||||
$('#register_form .otp-input-group input[tabindex="' + tabIndex + '"]').focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
loginForm.find("#User_Email,#User_password").keypress(function (e) {
|
||||
if (e.which == 13)
|
||||
document.getElementById("Login_btn").click();
|
||||
|
||||
});
|
||||
|
||||
$("#Login_btn").click(function () {
|
||||
loginForm.find(".loader-btn").show();
|
||||
$(this).hide();
|
||||
let userEmail = loginForm.find("#User_Email").val();
|
||||
let userPassword = loginForm.find("#User_password").val();
|
||||
let emailInput = loginForm.find(".email-login-inputgroup");
|
||||
let passwordInput = loginForm.find(".password-login-inputgroup");
|
||||
if (userEmail == "") {
|
||||
emailInput.find('#User_Email').addClass('is-invalid');
|
||||
emailInput.find('.form-floating').addClass('is-invalid');
|
||||
emailInput.find('.invalid-feedback').text('Please enter your email');
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
|
||||
}
|
||||
if (userPassword == "") {
|
||||
passwordInput.find('#User_password').addClass('is-invalid');
|
||||
passwordInput.find('.form-floating').addClass('is-invalid');
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
else {
|
||||
emailInput.find('#User_Email').removeClass('is-invalid');
|
||||
emailInput.find('.form-floating').removeClass('is-invalid');
|
||||
passwordInput.find('#User_password').removeClass('is-invalid');
|
||||
passwordInput.find('.form-floating').removeClass('is-invalid');
|
||||
if (validateEmail(userEmail)) {
|
||||
let port = SERVERNAME
|
||||
// let port = "http://localhost:3088";
|
||||
let url = `${port}/account/getuserbyphoneormail/${userEmail}/${userEmail}`;
|
||||
getDataStatAxios(url, userEmail);
|
||||
} else {
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
emailInput.find('#User_Email').addClass('is-invalid');
|
||||
emailInput.find('.form-floating').addClass('is-invalid');
|
||||
emailInput.find('.invalid-feedback').text('Please enter a valid email');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function getDataStatAxios(url, userEmail) {
|
||||
const config = {
|
||||
url,
|
||||
method: "get",
|
||||
};
|
||||
let response = await axios(config);
|
||||
if (response.data.result == null) {
|
||||
$('.error-div').text(response.data.message);
|
||||
}
|
||||
else {
|
||||
let userEmail = $("#User_Email").val();
|
||||
let userPassword = $("#User_password").val();
|
||||
const loginPayload = {
|
||||
username: userEmail,
|
||||
Password: userPassword,
|
||||
UnibaseId: "",
|
||||
RememberMe: false,
|
||||
};
|
||||
const res = await postAPIService(
|
||||
`bizgaze/crm/webapi/crmuserlogin`,
|
||||
loginPayload
|
||||
);
|
||||
if (res.data.message == "200") {
|
||||
// Command: toastr["success"]("Logged in successfully")
|
||||
// toasterOpts();
|
||||
debugger;
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.data.result.sessionId,
|
||||
userid: res.data.result.userId,
|
||||
...res.data.result
|
||||
})
|
||||
// setInitLoginLocal();
|
||||
// window.localStorage.setItem("Useremail", userEmail);
|
||||
//window.localStorage.setItem("Userpassword", userPassword);
|
||||
//window.localStorage.setItem("Isloggedin", true);
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
window.location.href = `/index.html`;
|
||||
} else {
|
||||
$("#empt_num").removeClass("d-none text-success").text(res.data.message).addClass('text-danger');
|
||||
$(".my_avatar").attr("href", "./login.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this function will be triggered on new user registration
|
||||
async function userRegistration() {
|
||||
reg_form = $('#register_form');
|
||||
// reg_name = $("#User_Name").val();
|
||||
reg_email = reg_form.find("#User_Email").val();
|
||||
// reg_otp_email = $("#User_otp_Email").val();
|
||||
// reg_number = $("#user_number").val();
|
||||
reg_pwd = reg_form.find("#User_password").val();
|
||||
let userName = reg_email.split("@");
|
||||
let otpRes = null;
|
||||
const userRegistratioNPayload = {
|
||||
organizationtypeid: "2",
|
||||
organizationid: "0",
|
||||
contactid: "0",
|
||||
userid: "0",
|
||||
username: "0",
|
||||
users_phonenumber: "0",
|
||||
password: reg_pwd,
|
||||
users_emailaddress: "0",
|
||||
emailaddress: reg_email,
|
||||
contactname: userName[0],
|
||||
phonenumber: "0",
|
||||
branchid: "0",
|
||||
tenantname: "Anwi Systems",
|
||||
rolename: "Customer Admin",
|
||||
currencyid: "0",
|
||||
customerformuniqueid: "Bizgaze_Platform_Crm_RegisterCRMUser",
|
||||
};
|
||||
$('.spinner-border').removeClass('d-none');
|
||||
const res = await postAPIService(
|
||||
`bizgaze/crm/webapi/registercrmuser`,
|
||||
userRegistratioNPayload
|
||||
);
|
||||
$('.spinner-border').addClass('d-none');
|
||||
if (res.data.message == "User Already Exists!") {
|
||||
$('.error-div').text('User Already Exists!');
|
||||
// $(".useralready_exist").removeClass("d-none");
|
||||
} else {
|
||||
}
|
||||
|
||||
$("#proceed").click(async function () {
|
||||
let userEnterOtp = "";
|
||||
let userEmail = registerForm.find("#User_Email").val();
|
||||
$('.otp-input-group input').each(function () {
|
||||
let presVal = $(this).val();
|
||||
userEnterOtp += presVal;
|
||||
})
|
||||
const userotppayload = {
|
||||
email: userEmail,
|
||||
otpid: res.data.result.OtpId,
|
||||
userotp: userEnterOtp,
|
||||
};
|
||||
$('.spinner-border').removeClass('d-none');
|
||||
otpRes = await postAPIService(
|
||||
`bizgaze/crm/webapi/ValidateOtp`,
|
||||
userotppayload
|
||||
);
|
||||
$('.spinner-border').addClass('d-none');
|
||||
const verifyotpStatus = otpRes.data.result;
|
||||
if (verifyotpStatus == "Otp verified successfully") {
|
||||
alert("Account created successfully");
|
||||
window.location.href = `/myaccount.html`;
|
||||
} else {
|
||||
alert("please enter valid otp");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// to validate password on keyup in password input field
|
||||
function passwordValidate(pswd) {
|
||||
if (pswd.length < 11) {
|
||||
$('#chck_length').removeClass('pswd_valid').addClass('pswd_invalid');
|
||||
} else {
|
||||
$('#chck_length').removeClass('pswd_invalid').addClass('pswd_valid');
|
||||
}
|
||||
// validate uppercase letter
|
||||
if (pswd.match(/[A-Z]/)) {
|
||||
$('#chck_capital').removeClass('pswd_invalid').addClass('pswd_valid');
|
||||
} else {
|
||||
$('#chck_capital').removeClass('pswd_valid').addClass('pswd_invalid');
|
||||
}
|
||||
//validate special letter
|
||||
if (pswd.match(/[!@#$%^&*]/)) {
|
||||
$('#chck_special').removeClass('pswd_invalid').addClass('pswd_valid');
|
||||
} else {
|
||||
$('#chck_special').removeClass('pswd_valid').addClass('pswd_invalid');
|
||||
}
|
||||
let pswdVal = $('#register_form #User_password').val();
|
||||
let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{11,}$/;
|
||||
if (pswdVal.match(pattern)) {
|
||||
$('#pswd_info').hide()
|
||||
}
|
||||
else {
|
||||
$('#pswd_info').show()
|
||||
}
|
||||
//validate number
|
||||
if (pswd.match(/\d/)) {
|
||||
$('#chck_number').removeClass('pswd_invalid').addClass('pswd_valid');
|
||||
} else {
|
||||
$('#chck_number').removeClass('pswd_valid').addClass('pswd_invalid');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//you have to use keyup, because keydown will not catch the currently entered value
|
||||
$('#register_form #User_password').keyup(function () {
|
||||
// set password variable
|
||||
var pswd = $(this).val();
|
||||
passwordValidate(pswd);
|
||||
}).focus(function () {
|
||||
let pswdVal = $('#register_form #User_password').val();
|
||||
let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{11,}$/;
|
||||
if (pswdVal.match(pattern)) {
|
||||
$('#pswd_info').hide()
|
||||
}
|
||||
else {
|
||||
$('#pswd_info').show()
|
||||
}
|
||||
}).blur(function () {
|
||||
$('#pswd_info').hide();
|
||||
});
|
||||
|
||||
// function to validate user entered email
|
||||
function validateEmail(userEmail) {
|
||||
var pattern =
|
||||
/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
|
||||
return $.trim(userEmail).match(pattern) ? true : false;
|
||||
}
|
||||
|
||||
// function to validate user entered password
|
||||
function validatepassword(userPassword) {
|
||||
var pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{11,}$/;
|
||||
return $.trim(userPassword).match(pattern) ? true : false;
|
||||
}
|
||||
|
||||
registerForm.find("#User_Email,#User_password").keypress(function (e) {
|
||||
if (e.which == 13)
|
||||
document.getElementById("register_btn").click();
|
||||
|
||||
});
|
||||
|
||||
// this will be triggered on clicking continue in signup form
|
||||
$("#register_btn").click(function () {
|
||||
registerForm.find(".loader-btn").show();
|
||||
$(this).hide();
|
||||
let userEmail = registerForm.find("#User_Email").val();
|
||||
let userPassword = registerForm.find("#User_password").val();
|
||||
let emailInput = registerForm.find(".email-login-inputgroup");
|
||||
let passwordInput = registerForm.find(".password-login-inputgroup");
|
||||
if (userEmail == "") {
|
||||
emailInput.find('#User_Email').addClass('is-invalid');
|
||||
emailInput.find('.form-floating').addClass('is-invalid');
|
||||
emailInput.find('.invalid-feedback').text('Please enter your email');
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
if (userPassword == "") {
|
||||
passwordInput.find('#User_password').addClass('is-invalid');
|
||||
passwordInput.find('.form-floating').addClass('is-invalid');
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
else {
|
||||
emailInput.find('#User_Email').removeClass('is-invalid');
|
||||
emailInput.find('.form-floating').removeClass('is-invalid');
|
||||
passwordInput.find('#User_password').removeClass('is-invalid');
|
||||
passwordInput.find('.form-floating').removeClass('is-invalid');
|
||||
if (validateEmail(userEmail)) {
|
||||
$('#register_form .email-password-group').hide();
|
||||
$('#register_form .otp-input-group').show();
|
||||
$('#register_form .otp-input-group .otp-sent-email').text(userEmail);
|
||||
userRegistration();
|
||||
} else {
|
||||
emailInput.find('#User_Email').addClass('is-invalid');
|
||||
emailInput.find('.form-floating').addClass('is-invalid');
|
||||
emailInput.find('.invalid-feedback').text('Please enter a valid email');
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#forgotPassword').click(function () {
|
||||
$('.login-email-password-div').hide();
|
||||
$('.login-forgot-passsword-div').show();
|
||||
})
|
||||
|
||||
function toasterOpts() {
|
||||
toastr.options = {
|
||||
"closeButton": true,
|
||||
"debug": false,
|
||||
"newestOnTop": true,
|
||||
"progressBar": true,
|
||||
"positionClass": "toast-top-center",
|
||||
"preventDuplicates": true,
|
||||
"showDuration": "300",
|
||||
"hideDuration": "1000",
|
||||
"timeOut": "3000",
|
||||
"extendedTimeOut": "1000",
|
||||
"showEasing": "swing",
|
||||
"hideEasing": "linear",
|
||||
"showMethod": "fadeIn",
|
||||
"hideMethod": "fadeOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initLogin();
|
||||
Vendored
+760
@@ -0,0 +1,760 @@
|
||||
function initLogin() {
|
||||
// alert('as')
|
||||
// Command: toastr["success"]("Logged in successfully")
|
||||
// Command: toastr["success"]("My name is Inigo Montoya. You killed my father. Prepare to die!")
|
||||
|
||||
// toasterOpts();
|
||||
let reg_name, reg_email, reg_number, reg_pwd, reg_otp_email;
|
||||
let loginForm = $("#login_form");
|
||||
let registerForm = $("#register_form");
|
||||
|
||||
$("#register_form .otp-input-group input.press").on("paste", function (p) {
|
||||
var data = p.originalEvent.clipboardData.getData("text");
|
||||
var dataLength = data.length;
|
||||
|
||||
for (var i = 0; i < dataLength; i++) {
|
||||
var input = $(
|
||||
'#register_form .otp-input-group input[tabindex="' + (i + 1) + '"]'
|
||||
);
|
||||
input.val(data.charAt(i));
|
||||
if (input.val().length >= input.attr("maxlength")) {
|
||||
var nextInput = $(
|
||||
'#register_form .otp-input-group input[tabindex="' + (i + 2) + '"]'
|
||||
);
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.preventDefault();
|
||||
});
|
||||
|
||||
$('#register_form .otp-input-group input[type="text"]').on(
|
||||
"keyup",
|
||||
function (e) {
|
||||
if ($(this).val().length >= $(this).attr("maxlength")) {
|
||||
if (e.keyCode !== 9 && e.keyCode !== 16) {
|
||||
var tabIndex = parseInt($(this).attr("tabindex")) + 1;
|
||||
$(
|
||||
'#register_form .otp-input-group input[tabindex="' +
|
||||
$(this).attr("tabindex") +
|
||||
'"]'
|
||||
).val($(this).val());
|
||||
$(
|
||||
'#register_form .otp-input-group input[tabindex="' + tabIndex + '"]'
|
||||
).focus();
|
||||
}
|
||||
} else {
|
||||
if (e.keyCode === 8) {
|
||||
var tabIndex = parseInt($(this).attr("tabindex")) - 1;
|
||||
$(
|
||||
'#register_form .otp-input-group input[tabindex="' + tabIndex + '"]'
|
||||
).focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
loginForm.find("#User_Email,#User_password").keypress(function (e) {
|
||||
if (e.which == 13) $("#Login_btn").click();
|
||||
});
|
||||
|
||||
$("#Login_btn").click(function () {
|
||||
$('.error_msg').hide();
|
||||
// loginForm.find(".loader-btn").show();
|
||||
let userEmail = loginForm.find("#User_Email").val();
|
||||
let userPassword = loginForm.find("#User_password").val();
|
||||
let emailInput = loginForm.find(".email-login-inputgroup");
|
||||
let passwordInput = loginForm.find(".password-login-inputgroup");
|
||||
if (userEmail == "") {
|
||||
emailInput.find("#User_Email").addClass("is-invalid");
|
||||
emailInput.find(".form-floating").addClass("is-invalid");
|
||||
emailInput.find(".invalid-feedback").text("Please enter your email");
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
if (userPassword == "") {
|
||||
passwordInput.find("#User_password").addClass("is-invalid");
|
||||
passwordInput.find(".form-floating").addClass("is-invalid");
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
} else {
|
||||
emailInput.find("#User_Email").removeClass("is-invalid");
|
||||
emailInput.find(".form-floating").removeClass("is-invalid");
|
||||
passwordInput.find("#User_password").removeClass("is-invalid");
|
||||
passwordInput.find(".form-floating").removeClass("is-invalid");
|
||||
if (validateEmail(userEmail)) {
|
||||
let port = SERVERNAME
|
||||
// let port = "http://localhost:3088";
|
||||
let url = `${port}/account/getuserbyphoneormail/${userEmail}/${userEmail}`;
|
||||
getDataStatAxios(url, userEmail);
|
||||
} else {
|
||||
loginForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
emailInput.find("#User_Email").addClass("is-invalid");
|
||||
emailInput.find(".form-floating").addClass("is-invalid");
|
||||
emailInput.find(".invalid-feedback").text("Please enter a valid email");
|
||||
}
|
||||
}
|
||||
});
|
||||
async function getDataStatAxios(url, userEmail) {
|
||||
const config = {
|
||||
url,
|
||||
method: "get",
|
||||
};
|
||||
let response = await axios(config);
|
||||
if (response.data.result == null) {
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html(`User doesn't exists with the email, <a href="#" class="alert-link register_sectionbtn" id="register_sectionbtn">Sign Up </a>`);
|
||||
$(".register_sectionbtn").click(function(){
|
||||
|
||||
|
||||
$(".login_section").css("display","none");
|
||||
$(".register_section").css("display","block");
|
||||
$(".login_section").find("#User_Email").removeClass("is-invalid");
|
||||
$(".login_section").find(".form-floating").removeClass("is-invalid");
|
||||
$(".login_section").find("#User_password").removeClass("is-invalid");
|
||||
$(".login_section").find(".form-floating").removeClass("is-invalid");
|
||||
$('.error_msg').hide();
|
||||
});
|
||||
// toasterOpts();
|
||||
|
||||
// Command: toastr["error"]("Please enter Valid email / password");
|
||||
} else {
|
||||
let userEmail = $("#User_Email").val();
|
||||
let userPassword = $("#User_password").val();
|
||||
const loginPayload = {
|
||||
username: userEmail,
|
||||
Password: userPassword,
|
||||
UnibaseId: "",
|
||||
RememberMe: false,
|
||||
};
|
||||
$("#Login_btn").hide();
|
||||
$(".loader-btn").show();
|
||||
const res = await postAPIService(
|
||||
`bizgaze/crm/webapi/crmuserlogin`,
|
||||
loginPayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$("#Login_btn").show();
|
||||
if (res.data.message == "200") {
|
||||
debugger;
|
||||
// Command: toastr["success"]("Logged in successfully")
|
||||
// toasterOpts();
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.data.result.sessionId,
|
||||
userid: res.data.result.userId,
|
||||
...res.data.result
|
||||
});
|
||||
// setInitLoginLocal();
|
||||
window.localStorage.setItem("Useremail", userEmail);
|
||||
//window.localStorage.setItem("Userpassword", userPassword);
|
||||
window.localStorage.setItem("Isloggedintoaster", true);
|
||||
window.localStorage.setItem("Isloggedin", true);
|
||||
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = `./index.html`;
|
||||
} else {
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html(res.data.message + ' <a class="validate_mail text-danger"><b>Validate Email</b></a>');
|
||||
// toasterOpts();
|
||||
// Command: toastr["error"]()
|
||||
/*Email validation*/
|
||||
$('.validate_mail').click(function(){
|
||||
$(".login_section").hide();
|
||||
$(".email-validate-div").show();
|
||||
$('.error_msg').hide();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this function will be triggered on new user registration
|
||||
async function userRegistration() {
|
||||
reg_form = $("#register_form");
|
||||
// reg_name = $("#User_Name").val();
|
||||
reg_email = reg_form.find("#User_Email").val();
|
||||
// reg_otp_email = $("#User_otp_Email").val();
|
||||
// reg_number = $("#user_number").val();
|
||||
reg_pwd = reg_form.find("#User_password").val();
|
||||
let userName = reg_email.split("@");
|
||||
let otpRes = null;
|
||||
const userRegistratioNPayload = {
|
||||
organizationtypeid: "2",
|
||||
organizationid: "0",
|
||||
contactid: "0",
|
||||
userid: "0",
|
||||
username: "0",
|
||||
users_phonenumber: "0",
|
||||
password: reg_pwd,
|
||||
users_emailaddress: "0",
|
||||
emailaddress: reg_email,
|
||||
contactname: userName[0],
|
||||
phonenumber: "0",
|
||||
branchid: "0",
|
||||
tenantname: "Anwi Systems",
|
||||
rolename: "Customer Admin",
|
||||
currencyid: "0",
|
||||
customerformuniqueid: "Bizgaze_Platform_Crm_RegisterCRMUser",
|
||||
};
|
||||
debugger;
|
||||
$('#register_btn').hide()
|
||||
$(".loader-btn").show();
|
||||
debugger;
|
||||
const res = await postAPIService(
|
||||
`bizgaze/crm/webapi/registercrmuser`,
|
||||
userRegistratioNPayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$('#register_btn').show()
|
||||
if (res.data.code == "404" ) {
|
||||
// toasterOpts();
|
||||
// Command: toastr["error"](res.data.message)
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html(res.data.message);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$("#register_form .email-password-group").hide();
|
||||
$("#register_form .register_otp.otp-input-group").show();
|
||||
}
|
||||
|
||||
$("#proceed").click(async function () {
|
||||
let userEnterOtp = "";
|
||||
let userEmail = registerForm.find("#User_Email").val();
|
||||
$(".otp-input-group input").each(function () {
|
||||
let presVal = $(this).val();
|
||||
userEnterOtp += presVal;
|
||||
});
|
||||
const userotppayload = {
|
||||
email: userEmail,
|
||||
otpid: res.data.result.OtpId,
|
||||
userotp: userEnterOtp,
|
||||
};
|
||||
$(".loader-btn").show();
|
||||
$('#proceed').hide()
|
||||
otpRes = await postAPIService(
|
||||
`bizgaze/crm/webapi/ValidateOtp`,
|
||||
userotppayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$('#proceed').show();
|
||||
const verifyotpStatus = otpRes.data.result;
|
||||
if (verifyotpStatus == "Otp verified successfully") {
|
||||
const loginPayload = {
|
||||
username: reg_email,
|
||||
Password: reg_pwd,
|
||||
UnibaseId: "",
|
||||
RememberMe: false,
|
||||
};
|
||||
const res = await postAPIService(
|
||||
`bizgaze/crm/webapi/crmuserlogin`,
|
||||
loginPayload
|
||||
);
|
||||
if (res.data.message == "200") {
|
||||
debugger;
|
||||
// Command: toastr["success"]("Logged in successfully")
|
||||
// toasterOpts();
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.data.result.sessionId,
|
||||
userid: res.data.result.userId,
|
||||
...res.data.result
|
||||
});
|
||||
// setInitLoginLocal();
|
||||
window.localStorage.setItem("Useremail", userEmail);
|
||||
//window.localStorage.setItem("Userpassword", userPassword);
|
||||
window.localStorage.setItem("isaccountCreated", true);
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
window.location.href = `./index.html`;
|
||||
} else {
|
||||
// toasterOpts();
|
||||
// Command: toastr["error"](res.data.message)
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html(res.data.message);
|
||||
}
|
||||
} else {
|
||||
// toasterOpts();
|
||||
// Command: toastr["error"]("Please enter Valid OTP");
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html("Please enter Valid OTP");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// to validate password on keyup in password input field
|
||||
function passwordValidate(pswd) {
|
||||
if (pswd.length < 8) {
|
||||
$("#chck_length").removeClass("pswd_valid").addClass("pswd_invalid");
|
||||
} else {
|
||||
$("#chck_length").removeClass("pswd_invalid").addClass("pswd_valid");
|
||||
}
|
||||
// validate uppercase letter
|
||||
if (pswd.match(/[A-Z]/)) {
|
||||
$("#chck_capital").removeClass("pswd_invalid").addClass("pswd_valid");
|
||||
} else {
|
||||
$("#chck_capital").removeClass("pswd_valid").addClass("pswd_invalid");
|
||||
}
|
||||
//validate special letter
|
||||
if (pswd.match(/[!@#$%^&*]/)) {
|
||||
$("#chck_special").removeClass("pswd_invalid").addClass("pswd_valid");
|
||||
} else {
|
||||
$("#chck_special").removeClass("pswd_valid").addClass("pswd_invalid");
|
||||
}
|
||||
let pswdVal = $("#register_form #User_password").val();
|
||||
let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/;
|
||||
if (pswdVal.match(pattern)) {
|
||||
$(".pswd_info").hide();
|
||||
} else {
|
||||
$(".pswd_info").show();
|
||||
}
|
||||
//validate number
|
||||
if (pswd.match(/\d/)) {
|
||||
$("#chck_number").removeClass("pswd_invalid").addClass("pswd_valid");
|
||||
} else {
|
||||
$("#chck_number").removeClass("pswd_valid").addClass("pswd_invalid");
|
||||
}
|
||||
}
|
||||
|
||||
//you have to use keyup, because keydown will not catch the currently entered value
|
||||
$("#register_form #User_password")
|
||||
.keyup(function () {
|
||||
// set password variable
|
||||
var pswd = $(this).val();
|
||||
passwordValidate(pswd);
|
||||
})
|
||||
.focus(function () {
|
||||
let pswdVal = $("#register_form #User_password").val();
|
||||
let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{11,}$/;
|
||||
if (pswdVal.match(pattern)) {
|
||||
$(".pswd_info").hide();
|
||||
} else {
|
||||
$(".pswd_info").show();
|
||||
}
|
||||
})
|
||||
.blur(function () {
|
||||
$(".pswd_info").hide();
|
||||
});
|
||||
|
||||
// function to validate user entered email
|
||||
function validateEmail(userEmail) {
|
||||
var pattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
|
||||
// return $.trim(userEmail).test(pattern) ? true : false;
|
||||
return pattern.test(userEmail) ? true : false;
|
||||
}
|
||||
|
||||
// function to validate user entered password
|
||||
function validatepassword(userPassword) {
|
||||
var pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,15}$/;
|
||||
// return $.trim(userPassword).test(pattern) ? true : false;
|
||||
return pattern.test(userPassword) ? true : false;
|
||||
}
|
||||
|
||||
registerForm.find("#User_Email,#User_password").keypress(function (e) {
|
||||
if (e.which == 13) $("#register_btn").click();
|
||||
});
|
||||
|
||||
// this will be triggered on clicking continue in signup form
|
||||
$("#register_btn").click(function () {
|
||||
$('.error_msg').hide();
|
||||
registerForm.find(".loader-btn").show();
|
||||
$(this).hide();
|
||||
let userEmail = registerForm.find("#User_Email").val();
|
||||
let userPassword = registerForm.find("#User_password").val();
|
||||
let emailInput = registerForm.find(".email-login-inputgroup");
|
||||
let passwordInput = registerForm.find(".password-login-inputgroup");
|
||||
if (userEmail == "") {
|
||||
emailInput.find("#User_Email").addClass("is-invalid");
|
||||
emailInput.find(".form-floating").addClass("is-invalid");
|
||||
emailInput.find(".invalid-feedback").text("Please enter your email");
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
if (userPassword == "") {
|
||||
passwordInput.find("#User_password").addClass("is-invalid");
|
||||
passwordInput.find(".form-floating").addClass("is-invalid");
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
} else {
|
||||
emailInput.find("#User_Email").removeClass("is-invalid");
|
||||
emailInput.find(".form-floating").removeClass("is-invalid");
|
||||
passwordInput.find("#User_password").removeClass("is-invalid");
|
||||
passwordInput.find(".form-floating").removeClass("is-invalid");
|
||||
let Email_valid = validateEmail(userEmail);
|
||||
let Pwd_valid = validatepassword(userPassword);
|
||||
if (Email_valid === true && Pwd_valid === true) {
|
||||
userRegistration();
|
||||
$("#register_form .otp-input-group .otp-sent-email").text(userEmail);
|
||||
} else if(Email_valid === false) {
|
||||
emailInput.find("#User_Email").addClass("is-invalid");
|
||||
emailInput.find(".form-floating").addClass("is-invalid");
|
||||
emailInput.find(".invalid-feedback").text("Please enter a valid email");
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}else if(Pwd_valid === false){
|
||||
passwordInput.find("#User_password").addClass("is-invalid");
|
||||
passwordInput.find(".form-floating").addClass("is-invalid");
|
||||
passwordInput.find(".invalid-feedback").text("Please check the password!");
|
||||
registerForm.find(".loader-btn").hide();
|
||||
$(this).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
$(".pswd_eye").click(function(){
|
||||
let eyeClass = $(this).find('svg').hasClass("fa-eye-slash");
|
||||
if(eyeClass == true){
|
||||
$(this).find('svg').removeClass("fa-eye-slash");
|
||||
$(this).find('svg').addClass("fa-eye");
|
||||
$(this).siblings('input').attr('type','password')
|
||||
}else{
|
||||
$(this).find('svg').removeClass("fa-eye");
|
||||
$(this).find('svg').addClass("fa-eye-slash");
|
||||
$(this).siblings('input').attr('type','text')
|
||||
}
|
||||
})
|
||||
|
||||
$("#forgotPassword").click(function () {
|
||||
$(".login-email-password-div").hide();
|
||||
$(".login-forgot-password-div").show();
|
||||
});
|
||||
$("#forgot_Password_Back").click(function () {
|
||||
$(".login-forgot-password-div").hide();
|
||||
$(".login-email-password-div").show();
|
||||
});
|
||||
$("#forgot_password_submit").click(async function () {
|
||||
let forgot_email = $("#forgot_User_Email").val();
|
||||
if(forgot_email == ''){
|
||||
$('#forgot_User_Email').addClass('is-invalid')
|
||||
$('#forgot_User_Email').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
|
||||
return
|
||||
}
|
||||
else{
|
||||
debugger;
|
||||
let port = SERVERNAME
|
||||
// let port = "http://localhost:3088";
|
||||
let url = `${port}/account/getuserbyphoneormail/${forgot_email}/${forgot_email}`;
|
||||
const config = {
|
||||
url,
|
||||
method: "get",
|
||||
};
|
||||
$(".loader-btn").show();
|
||||
$('#forgot_password_submit').hide()
|
||||
let response = await axios(config);
|
||||
$(".loader-btn").hide();
|
||||
$('#forgot_password_submit').show()
|
||||
if (response.data.result != null) {
|
||||
const forgotpassPayload = {
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
contactnumber: "",
|
||||
email: "",
|
||||
tenantname: "",
|
||||
contactoremail: response.data.result.email,
|
||||
IsSignup: false,
|
||||
IsRegisterUser: false,
|
||||
IsForgotPswd: true,
|
||||
UnibaseId: response.data.result.userName,
|
||||
OtpId: 0,
|
||||
UserOtp: "",
|
||||
};
|
||||
$('#forgot_password_submit').hide()
|
||||
$(".loader-btn").show();
|
||||
const forgetpassRes = await postAPIService(
|
||||
`account/sendotp`,
|
||||
forgotpassPayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$(".email-validation").hide();
|
||||
$('.user_email').html(forgot_email)
|
||||
$(".otp-validation .otp-input-group").show();
|
||||
$(".otp-validation .otp-input-group").on("paste", function (p) {
|
||||
let data = p.originalEvent.clipboardData.getData("text");
|
||||
let dataLength = data.length;
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let input = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' + (i + 1) + '"]'
|
||||
);
|
||||
input.val(data.charAt(i));
|
||||
if (input.val().length >= input.attr("maxlength")) {
|
||||
let nextInput = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
(i + 2) +
|
||||
'"]'
|
||||
);
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.preventDefault();
|
||||
});
|
||||
|
||||
$('.otp-validation .otp-input-group input[type="text"]').on(
|
||||
"keyup",
|
||||
function (e) {
|
||||
if ($(this).val().length >= $(this).attr("maxlength")) {
|
||||
if (e.keyCode !== 9 && e.keyCode !== 16) {
|
||||
let tabIndex = parseInt($(this).attr("tabindex")) + 1;
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
$(this).attr("tabindex") +
|
||||
'"]'
|
||||
).val($(this).val());
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
tabIndex +
|
||||
'"]'
|
||||
).focus();
|
||||
}
|
||||
} else {
|
||||
if (e.keyCode === 8) {
|
||||
let tabIndex = parseInt($(this).attr("tabindex")) - 1;
|
||||
$(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
tabIndex +
|
||||
'"]'
|
||||
).focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
$("#Forgot_pass_proceed").click(async function () {
|
||||
debugger;
|
||||
let userotp='';
|
||||
$(".otp-validation .otp-input-group input").each(function () {
|
||||
let presVal = $(this).val();
|
||||
userotp += presVal;
|
||||
});
|
||||
const validateForgotpass = {
|
||||
email: forgot_email,
|
||||
otpid: forgetpassRes.data,
|
||||
userotp: userotp,
|
||||
};
|
||||
$('#Forgot_pass_proceed').hide()
|
||||
$(".loader-btn").show();
|
||||
const forgetpassResotp = await postAPIService(
|
||||
`hyperfusion/validateotp`,
|
||||
validateForgotpass
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$('#Forgot_pass_proceed').show()
|
||||
const Resotp = forgetpassResotp.data.result;
|
||||
if (Resotp == "Otp verified successfully") {
|
||||
$(".login-forgot-password-details-div").show();
|
||||
$(".otp-validation .otp-input-group").hide();
|
||||
} else {
|
||||
// toasterOpts()
|
||||
// Command: toastr["error"]("Please enter Valid OTP");
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html("Please enter Valid OTP");
|
||||
}
|
||||
});
|
||||
$("#forgot_password_details_submit").click(async function () {
|
||||
debugger;
|
||||
let pswdone =$("#forgot-password-input-one").val();
|
||||
let pswdtwo =$("#forgot-password-input-two").val();
|
||||
if(pswdone == pswdtwo) {
|
||||
const forgotpassPayload = {
|
||||
username: response.data.result.userName,
|
||||
password: pswdtwo,
|
||||
};
|
||||
$("#forgot_password_details_submit").hide();
|
||||
$(".loader-btn").show();
|
||||
const forgetpassRes = await postAPIService(
|
||||
`account/UpdatePassword`,
|
||||
forgotpassPayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
$("#forgot_password_details_submit").show();
|
||||
window.localStorage.setItem('Ispasswordupdate',true)
|
||||
window.location.href = `./myaccount.html`;
|
||||
}else {
|
||||
$("#forgot-password-input-one").addClass('is-invalid');
|
||||
$("#forgot-password-input-two").addClass('is-invalid')
|
||||
$('.password_display').text('Passwords are not matched !').addClass('text-danger')
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
else{
|
||||
$('#forgot_User_Email').addClass('is-invalid');
|
||||
$('#forgot_User_Email').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
$(".user_pass")
|
||||
.keyup(function () {
|
||||
// set password variable
|
||||
var pswd = $(this).val();
|
||||
passwordValidate(pswd);
|
||||
$('.pswd_info').hide();
|
||||
$(this).parent().siblings('.pswd_info').show();
|
||||
})
|
||||
.focus(function () {
|
||||
let pswdVal = $(this).val();
|
||||
let pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/;
|
||||
if (pswdVal.match(pattern)) {
|
||||
$(this).parent().siblings('.pswd_info').hide();
|
||||
} else {
|
||||
$(this).parent().siblings('.pswd_info').show();
|
||||
}
|
||||
})
|
||||
.blur(function () {
|
||||
$(this).parent().siblings('.pswd_info').hide();
|
||||
});
|
||||
|
||||
function toasterOpts(){
|
||||
toastr.options = {
|
||||
"closeButton": true,
|
||||
"debug": false,
|
||||
"newestOnTop": true,
|
||||
"progressBar": true,
|
||||
"positionClass": "toast-top-center",
|
||||
"preventDuplicates": true,
|
||||
"onclick": null,
|
||||
"showDuration": "300",
|
||||
"hideDuration": "1000",
|
||||
"timeOut": "5000",
|
||||
"extendedTimeOut": "1000",
|
||||
"showEasing": "swing",
|
||||
"hideEasing": "linear",
|
||||
"showMethod": "fadeIn",
|
||||
"hideMethod": "fadeOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#email_validate_submit").click(async function () {
|
||||
let vaidate_otp;
|
||||
let validate_email = $("#email_validation_input").val();
|
||||
if(validate_email == ''){
|
||||
$('#email_validation_input').addClass('is-invalid')
|
||||
$('#email_validation_input').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
|
||||
return
|
||||
}
|
||||
else{
|
||||
debugger;
|
||||
let port = SERVERNAME;
|
||||
// let port = "http://localhost:3088";
|
||||
let url = `${port}/account/getuserbyphoneormail/${validate_email}/${validate_email}`;
|
||||
const config = {
|
||||
url,
|
||||
method: "get",
|
||||
};
|
||||
$(".loader-btn").show();
|
||||
$('#email_validate_submit').hide()
|
||||
let response = await axios(config);
|
||||
$(".loader-btn").hide();
|
||||
$('#email_validate_submit').show()
|
||||
if (response.data.result != null) {
|
||||
const forgotpassPayload = {
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
contactnumber: "",
|
||||
email: "",
|
||||
tenantname: "",
|
||||
contactoremail: response.data.result.email,
|
||||
IsSignup: false,
|
||||
IsRegisterUser: false,
|
||||
IsForgotPswd: true,
|
||||
UnibaseId: response.data.result.userName,
|
||||
OtpId: 0,
|
||||
UserOtp: "",
|
||||
};
|
||||
$('#email_validate_submit').hide()
|
||||
$(".loader-btn").show();
|
||||
const validate_email_res = await postAPIService(
|
||||
`account/sendotp`,
|
||||
forgotpassPayload
|
||||
);
|
||||
$(".loader-btn").hide();
|
||||
vaidate_otp = validate_email_res.data;
|
||||
$(".email-validation").hide();
|
||||
$('.user_email').html(validate_email)
|
||||
$(".otp-validation .otp-input-group").show();
|
||||
$(".otp-validation .otp-input-group").on("paste", function (p) {
|
||||
let data = p.originalEvent.clipboardData.getData("text");
|
||||
let dataLength = data.length;
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let input = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' + (i + 1) + '"]'
|
||||
);
|
||||
input.val(data.charAt(i));
|
||||
if (input.val().length >= input.attr("maxlength")) {
|
||||
let nextInput = $(
|
||||
'.otp-validation .otp-input-group input[tabindex="' +
|
||||
(i + 2) +
|
||||
'"]'
|
||||
);
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.preventDefault();
|
||||
});
|
||||
|
||||
}
|
||||
else{
|
||||
$('#email_validation_input').addClass('is-invalid');
|
||||
$('#email_validation_input').after(`<div class="invalid-feedback">Please enter Valid email</div>`);
|
||||
|
||||
}
|
||||
}
|
||||
$("#email_validate_proceed").click(async function () {
|
||||
debugger;
|
||||
let userotp='';
|
||||
let validate_email = $("#email_validation_input").val();
|
||||
$(".email-validate-div .otp-validation .otp-input-group input").each(function () {
|
||||
let presVal = $(this).val();
|
||||
userotp += presVal;
|
||||
});
|
||||
|
||||
if(userotp.length == 6){
|
||||
const validateForgotpass = {
|
||||
email: validate_email,
|
||||
otpid: vaidate_otp,
|
||||
userotp: userotp,
|
||||
};
|
||||
$('#email_validate_proceed').hide()
|
||||
$(".loader-btn").show();
|
||||
const validate_email_resopt = await postAPIService(
|
||||
`hyperfusion/validateotp`,
|
||||
validateForgotpass
|
||||
);
|
||||
|
||||
$(".loader-btn").hide();
|
||||
$('#email_validate_proceed').show()
|
||||
const Resotp = validate_email_resopt.data.result;
|
||||
if (Resotp == "Otp verified successfully") {
|
||||
$(".login_section").show();
|
||||
$(".otp-validation .otp-input-group").hide();
|
||||
$("#email_validate_back").hide();
|
||||
$('.error_msg').hide();
|
||||
} else {
|
||||
// toasterOpts()
|
||||
// Command: toastr["error"]("Please enter Valid OTP");
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html("Please enter Valid OTP");
|
||||
}
|
||||
}
|
||||
else{
|
||||
$('.error_msg').show();
|
||||
$('.error_msg .error_msg_res').html("Please enter OTP");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
initLogin();
|
||||
Reference in New Issue
Block a user