1(function () { 2 'use strict'; 3 4 var app = angular.module('app'); 5 6 app.directive('customerLoginIdstc', function ($rootScope, $q, $http, $location, shoppingCartModel, appService, translationService, beautysocietyPosthogService) { 7 return { 8 restrict: 'E', 9 scope: { 10 doRedirect: '=', // This is used as a popup for sharing so referring customers can login, in which case no redirect should happen, but if on regular page and user is already logged in or logging in, then user should be redirected 11 showConsultantLoginLink: '=?', // This is used to show a link that will allow users to login as a consultant 12 process: '=?', // This is used to indicate the process that the person is logging in from (ie.. Sharing, Wishlist) 13 showCreatePersonLink: '=?', // This is used to show a link that will allow users to create a new customer account 14 createPersonLink: '=?' // This is a url used to link the person to the create person page 15 }, 16 replace: true, 17 templateUrl: beautysocietyDirectivePluginRelativeUrl + '/assets/views/idstc/CustomerLoginIdstcDirective.html', 18 link: function (scope, element, attributes) { 19 scope.shoppingCartModel = shoppingCartModel; 20 scope.translationService = translationService; 21 scope.appService = appService; 22 shoppingCartModel.dataReady = false; 23 scope.showChooseUserAccount = false; 24 scope.customerEmail = null; 25 26 if (typeof scope.showConsultantLoginLink == 'undefined' || scope.showConsultantLoginLink == null) { 27 scope.showConsultantLoginLink = true; 28 } 29 30 if (typeof scope.showCreatePersonLink == 'undefined' || scope.showCreatePersonLink == null) { 31 scope.showCreatePersonLink = false; 32 } 33 34 scope.init = function () { 35 scope.recommendedCartId = idstc().getExpirableLocalStorageVar('RecommendedCartID', 120); 36 37 let promises = [appService.makeReady()]; 38 39 $q.all(promises).then(function (result) { 40 if (scope.appService.loggedIn && scope.appService.personTypeId == 1) { 41 scope.appService.logout(); 42 } 43 44 promises = [scope.translationService.getTranslations('user-log-in-form')]; 45 46 if (scope.recommendedCartId != null && scope.recommendedCartId != '') { 47 promises.push(scope.getCustomerEmailForOrderRecommendation(scope.recommendedCartId)); 48 } 49 50 $q.all(promises).then(function (result) { 51 if (scope.appService.loggedIn && scope.appService.personTypeId == 2) { 52 if ($location.search().portal == '1') { 53 $(document).progressStart(); 54 // go to the portal 55 appService.loginPortal(); 56 } 57 else { 58 // Redirect to home page if already logged in 59 if (scope.doRedirect) { 60 appService.getLanguagePrefix(localStorage.getItem('languageCode'), localStorage.getItem('countryCode')).then(function (result) { 61 window.location = result; 62 }); 63 } 64 } 65 } 66 else { 67 shoppingCartModel.dataReady = true; 68 } 69 }); 70 }); 71 } 72 73 scope.getCustomerEmailForOrderRecommendation = function (cartId) {
74 return $http.get(apiRoot + 'api/shopping/GetCustomerEmailForOrderRecommendation?cartId=' + cartId).then( 75 function (successResult) { 76 scope.customerUsername = successResult.data; 77 78 return successResult; 79 }); 80 } 81 82 scope.inputKeyPress = function (event) { 83 //if enter then hit the login button 84 if (event.charCode == 13) { 85 scope.loginCustomer(); 86 } 87 } 88 89 scope.loginCustomer = function (loginGuid, specificUsername) { 90 var oldUrl = document.referrer; 91 var returnUrl = ''; 92 var username = specificUsername || scope.customerUsername; 93 94 if (oldUrl && oldUrl.indexOf(idstcSettingAppName) >= 0) { 95 returnUrl = oldUrl; 96 scope.loginCustomerFinish(loginGuid, username, returnUrl); 97 } 98 else { 99 appService.getLanguagePrefix(localStorage.getItem('languageCode'), localStorage.getItem('countryCode')).then(function (result) { 100 if (result.length >= 2) { 101 returnUrl = result.substring(1); 102 } 103 104 scope.loginCustomerFinish(loginGuid, username, returnUrl); 105 }); 106 } 107 }; 108 109 scope.loginCustomerFinish = function (loginGuid, username, returnUrl) { 110 shoppingCartModel.userAccounts = null; 111 112 if (scope.loginFormCustomer.$valid) { 113 let promises = [beautysocietyPosthogService.trackLoginCustomerClick(window.location.href, 'Customer'), shoppingCartModel.login(username, scope.customerPassword, returnUrl, 2, loginGuid, scope.doRedirect)]; 114 $q.all(promises).then(function (result) { 115 if (scope.shoppingCartModel.userAccounts != null && scope.shoppingCartModel.userAccounts.length > 1) { 116 scope.userAccounts = scope.shoppingCartModel.userAccounts; 117 scope.showChooseUserAccount = true; 118 $(document).progressFinish(); 119 } 120 else { 121 $rootScope.$broadcast('customerLoginFinished', scope.process); 122 } 123 }); 124 } 125 else { 126 idstc().dialog({ 127 type: 'alert', 128 message: idstc().translate('user-log-in-form', 'FormInvalid', 'There are missing fields. Please correct them and try again.') 129 }, function () { 130 $(':input.ng-invalid').filter(':visible:first').focus(); 131 }); 132 } 133 } 134 135 scope.accountSelected = function () { 136 for (var i = 0; i < scope.userAccounts.length; i++) { 137 let account = scope.userAccounts[i]; 138 139 if (account.Selected) { 140 scope.loginCustomer(account.LoginGuid, account.Username); 141 break; 142 } 143 } 144 } 145 146 scope.init(); 147 } 148 } 149 }); 150})(); 151$("body").on('click', '.toggle-password', function () { 152 $(this).toggleClass("fa-eye fa-eye-slash"); 153 var input = $("#Password"); 154 if (input.attr("type") === "password") { 155 input.attr("type", "text"); 156 } else { 157 input.attr("type", "password"); 158 } 159});
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.