1clauthApp.service('clauthEmailService', function ($http, clauthSessionService, clauthUtilityService) { 2 3 const emailPattern = /^[a-zA-Z0-9._+!#$%&'*/=?^`{|}~\\-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,24}$/i; 4 5 this.validateEmailId = function (email) { 6 let validationResult = { 7 emailRequired: false, 8 emailFree: false, 9 isEmailInvalid: false, 10 emailInUse: false, 11 showNonHouseAccountEmailError: false, 12 showSaviyantSetupError: false, 13 showHouseAccountEmailError: false, 14 showOrganizationIdError: false, 15 }; 16 17 if (!email) { 18 validationResult.emailRequired = true; 19 } else if (!emailPattern.test(email) || email.includes('@.')) { 20 validationResult.isEmailInvalid = true; 21 } else if (clauthUtilityService.isFreeEmailDomain(email)) { 22 validationResult.emailFree = true; 23 } 24 return validationResult; 25 }; 26 27 this.validateEmailIdViaApi = function (email) { 28 return $http.post(window.location.origin + '/api/clauth/checkEmailInMappingTable', email) 29 .then(function (response) { 30 if (response.data.sessionExpiryUrl != null) { 31 window.location.href = response.data.sessionExpiryUrl; 32 } else { 33 if (response.data.isEmailInMappingTable) { 34 return {emailInUse: true}; 35 } else { 36 return {emailInUse: false}; 37 } 38 } 39 }) 40 .catch(function (error) { 41 if (error.status === 401) { 42 clauthUtilityService.safeRedirect(error.data.sessionExpiryUrl); 43 } else { 44 console.error("Error occurred:", error); 45 } 46 }); 47 }; 48 49 this.sendVerificationCodeViaEmail = function (email) { 50 return $http.post(window.location.origin + '/api/clauth/send-code', email) 51 .then(function (response) { 52 if (response.data.sessionExpiryUrl != null) { 53 clauthUtilityService.safeRedirect(response.data.sessionExpiryUrl); 54 } else { 55 return response.data; 56 } 57 }) 58 .catch(function (error) { 59 if (error.status === 401) { 60 clauthUtilityService.safeRedirect(error.data.sessionExpiryUrl); 61 } else if (error.status === 400) { 62 return error.data; 63 } else { 64 console.error("Error occurred:", error); 65 } 66 }); 67 }; 68});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.