Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mobilnewregisteruser.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. var Unibase;
  2. (function (Unibase) {
  3. let Themes;
  4. (function (Themes) {
  5. let Compact;
  6. (function (Compact) {
  7. let Components;
  8. (function (Components) {
  9. class MobilNewRegisterUser extends Unibase.Platform.Core.BaseComponent {
  10. jsFiles() {
  11. return ["tenants/themes/compact/index.mobil_anonymous.js", "platform/membership/managers/accountmanager.js", "libs/passwordrequirement/passwordrequirement.js"];
  12. }
  13. cssFiles() {
  14. return ["libs/passwordrequirement/passwordrequirement.css"];
  15. }
  16. html(id, containerid) {
  17. if (jQuery("#external-form").length === 0) {
  18. var index = new Components.Index_Mobil_Anonymous();
  19. index.init(null);
  20. }
  21. let html = '';
  22. if (($(window).width()) > 1200) {
  23. html += `<div class="row h-100"> <div class="col-xl-5"><div class="banner-img-container h-100"><img src="tenants/themes/compact/imgs/mobil-desktop-view-bg.png" alt="img" class="h-100 w-100"> </div> </div> <div class="col-xl-7 desktop-view"> <form class="mt-100" id="frm_RegisterUser" default="" data-validate="parsley" data-isdynamic="false"> <div id="div_ValidationSummary"></div> <div id="div_RegisterUser"><h1 class="display-4 mb-30 text-dark-100 text-center">Registration</h1>
  24. <div class="alert alert-primary d-none">We will send new code to your <a href=""><u>Email or Phone</u></a> to create your password.</div> <div class="form-group"><input class="form-control" required placeholder="Enter Registered Phone Number" id="txt_EmailorPhone" type="text"></div> <div class="form-group floating-label-form-group floating-label-form-group-with-value focus" id="div_TenantsAutoComplete"><select id="ddl_Tenant" class=" form-control value-control" data-isdynamic="false"></select></div><button class="btn text-white btn-block" type="button" id="btn_SendOtp" style="background:#001F5D;">Confirm</button><p class="text-right mt-20"><a href="Index.html#/login">Back to login</a></p></div> <div id="div_CreatePswd" class="d-none"> <h1 class="display-5 mb-30 text-center">Create your Password</h1>
  25. <div class="form-group"><label class="form-control" id="lbl_Email"></label></div><div class="form-group"><input class="form-control pr-password " required id="txt_NewPswd" placeholder="New password" type="password"><span toggle="#txt_NewPswd" id="passwordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span>
  26. <div class="showpwsdreq"></div> </div> <div class="form-group"><input class="form-control" required id="txt_ConfirmPswd" placeholder="Re-enter new password" type="password" autocomplete="new-password"><span toggle="#txt_ConfirmPswd" id="confirmPasswordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span></div>
  27. <button class="btn text-white btn-block mb-20" disabled="disabled" type="button" id="btn_CreatePswd" style="background:#001F5D;">Create Password</button> <div class="input-group mb-20"><div class="custom-control custom-checkbox col-xs"><input class="custom-control-input" id="InputTermsandConditions" type="checkbox"><label class="custom-control-label font-14" for="InputTermsandConditions">I accept the terms & conditions</label></div></div><p class="text-right"><a href="Index.html#/login">Back to login</a></p></div> <div id="div_SuccessMsg" class="d-none"> <div class="d-62 bg-white rounded-circle mb-10 d-flex align-items-center justify-content-center mx-auto"><i class="fa fa-check font-50 text-success"></i></div> <h1 class="display-4 mb-20 text-center">Password Created Successfully</h1> <p class="text-center"><a href="Index.html#/login">Click here to Login</a></p> </div></form> </div></div>`;
  28. }
  29. else {
  30. html += `<div><form id="frm_RegisterUser" default="" class="p-4 " data-validate="parsley" data-isdynamic="false" style="background: url(tenants/themes/compact/imgs/mobil-background.png) no-repeat;"><div id="div_ValidationSummary" class="position-fixed w-85"></div><div id="div_RegisterUser"> <div class="d-flex flex-column justify-content-around p-3 mt-4" style="height:100vh"> <div class="form-group-body"> <div class=" mx-auto mb-20"><h1 class="display-4 mb-60 text-white text-center font-weight-bold">Registration</h1></div> <div class="alert alert-primary d-none">We will send new code to your <a href=""><u>Email or Phone</u></a> to create your password.</div><div class="form-group mb-20"><input class="form-control" required autocomplete="off" placeholder="Enter Registered Email or Phone" id="txt_EmailorPhone" type="text"></div><div class="form-group floating-label-form-group floating-label-form-group-with-value focus" id="div_TenantsAutoComplete"><select id="ddl_Tenant" class="form-control value-control" data-isdynamic="false"></select></div> <p class="text-right "><a href="Index.html#/login" class="text-white">Back to login</a></p> </div> <div class="footer-register"><button class="btn btn-block rounded-10 text-white" type="button" style="background:#001F5D; padding: 10px !important;" id="btn_SendOtp">Confirm</button> </div> </div></div><div id="div_CreatePswd" class="d-none"><div class="d-flex flex-column justify-content-around" style="height: 100vh"> <div class="form-group"> <h1 class="display-5 text-white my-50 font-weight-bold text-center">Create your Password</h1><div class="form-group"><input class="form-control pr-password" required id="txt_NewPswd" placeholder="New password" type="password" autocomplete="new-password"><span toggle="#txt_NewPswd" id="passwordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span> <div class="showpwsdreq"></div></div> <div class="form-group"><input class="form-control" required id="txt_ConfirmPswd" placeholder="Re-enter new password" type="password" autocomplete="new-password"><span toggle="#txt_ConfirmPswd" id="confirmPasswordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span></div></div> <div class="form-footer"> <button class="btn btn-primary btn-block mb-20 rounded-10" type="button" id="btn_CreatePswd" style="background:#001F5D; padding: 10px !important;">Create Password</button> </div> </div></div> <div id="div_SuccessMsg" class="d-none"> <div class="d-62 bg-white rounded-circle mb-10 d-flex align-items-center justify-content-center mx-auto"><i class="fa fa-check font-50 text-success"></i></div> <h1 class="display-4 mb-20 text-center">Password Created Successfully</h1> <p class="text-center"><a href="Index.html#/login">Click here to Login</a></p></div></form></div>`;
  31. }
  32. html += `<div id="modal_Otp" class="modal fade hide"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header mt-2 mb-2"> <h5 class="modal-title pull-left">Mobile or Email Verification</h5><button type="button" class="btn btn-primary btn-simple pull-right" data-dismiss="modal" aria-hidden="true">&times;</button></div> <div class="modal-body" id="div_modalbody"> <div class="mb-10"> <p class="lbl_Otp">We have sent OTP on your Mobile Number and Email!</p> </div> <div class="floating-label-form-group mb-2"><input class="form-control" id="txt_Otp" placeholder="Enter Mobile OTP/Email OTP" type="password" autocomplete="new-password"><span toggle="#txt_Otp" id="OtpHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span></div> </div> <div class="modal-footer mb-2" style="display:block"><button type="button" class="btn btn-primary pull-left" id="btn_ResendOtp">Resend</button><button type="button" class="btn btn-primary pull-right" id="btn_VerifyOtp">Verify</button></div> </div></div></div>`;
  33. return html;
  34. }
  35. load(id, containerid, callback) {
  36. this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance();
  37. this.loadTenants();
  38. jQuery(".preloader-it").delay(500).fadeOut("slow");
  39. jQuery("#external-container").delay(500).fadeIn("slow");
  40. jQuery("#bizgaze_body").css("background-color", "#f4f6f7");
  41. $("#div_modalbody").removeAttr("style");
  42. $(".pr-password").click(function () {
  43. var signUpPswd = $(".pr-password");
  44. signUpPswd.passwordRequirements({
  45. numCharacters: 8,
  46. useLowercase: true,
  47. useUppercase: true,
  48. useNumbers: true,
  49. useSpecial: true
  50. });
  51. });
  52. $("#passwordHide").click(function () {
  53. var input = $('#txt_NewPswd');
  54. input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password');
  55. $("#passwordHide").toggleClass('fa-eye-slash fa-eye');
  56. });
  57. $("#confirmPasswordHide").click(function () {
  58. var input = $('#txt_ConfirmPswd');
  59. input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password');
  60. $('#confirmPasswordHide').toggleClass('fa-eye-slash fa-eye');
  61. });
  62. $("#OtpHide").click(function () {
  63. var input = $('#txt_Otp');
  64. input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password');
  65. $('#OtpHide').toggleClass('fa-eye-slash fa-eye');
  66. });
  67. $("#txt_EmailorPhone").keypress(function (e) {
  68. if (e.which == 13)
  69. document.getElementById("btn_SendOtp").click();
  70. });
  71. $("#txt_Otp").keypress(function (e) {
  72. if (e.which == 13)
  73. document.getElementById("btn_VerifyOtp").click();
  74. });
  75. $("#txt_NewPswd,#txt_ConfirmPswd").keypress(function (e) {
  76. if (e.which == 13)
  77. document.getElementById("btn_CreatePswd").click();
  78. });
  79. var instance = this;
  80. $("#btn_SendOtp").click(function () {
  81. instance.validate();
  82. });
  83. $(".btn_SendOtp").click(function () {
  84. instance.validate();
  85. });
  86. $("#btn_CreatePswd").click(function () {
  87. instance.createPassword();
  88. });
  89. $("#btn_VerifyOtp").click(function () {
  90. instance.verifyOtp();
  91. });
  92. $("#btn_ResendOtp").click(function () {
  93. instance.sendOtp(instance.OtpId);
  94. });
  95. if (callback != null)
  96. callback();
  97. }
  98. loadTenants() {
  99. var instance = this;
  100. instance._accountManager.getTenants().then(function (response) {
  101. var res = response;
  102. let cmbLob = document.getElementById('ddl_Tenant');
  103. $('#ddl_Tenant').empty();
  104. $('#ddl_Tenant').append('<option value=0>Select Tenant</option>');
  105. for (var i = 0; i < response.result.length; i++) {
  106. var data = response.result[i];
  107. var opt = document.createElement("option");
  108. var Name = data.tenantName;
  109. var id = data.tenantId;
  110. opt.text = Name;
  111. opt.value = id;
  112. cmbLob.append(opt);
  113. }
  114. if (res.result.filter(x => x.isTemplateDb == false).length == 1) {
  115. var Id = $('#ddl_Tenant option[value=' + res.result.filter(x => x.isTemplateDb == false)[0].tenantId + ']');
  116. Id.attr("selected", true);
  117. $("#ddl_Tenant").prop('disabled', true);
  118. }
  119. });
  120. }
  121. validate() {
  122. $(".lbl_Otp").text("");
  123. $("#txt_Otp").val('');
  124. $("#div_ValidationSummary").empty();
  125. var phoneOrEmail = $("#txt_EmailorPhone").val();
  126. var tenantId = $("#ddl_Tenant option:selected").val();
  127. if (phoneOrEmail == "" && tenantId == 0) {
  128. MessageHelper.Instance().showError("Please enter Email/Phone and select a Tenant !", "div_ValidationSummary");
  129. return false;
  130. }
  131. if (phoneOrEmail == "") {
  132. MessageHelper.Instance().showError("Email or Phone cannot be Empty!", "div_ValidationSummary");
  133. return false;
  134. }
  135. if (tenantId == 0) {
  136. MessageHelper.Instance().showError("Please select a Tenant", "div_ValidationSummary");
  137. return false;
  138. }
  139. else {
  140. var instance = this;
  141. instance._accountManager.getContact(phoneOrEmail, tenantId).then(function (response) {
  142. if (response.result != null) {
  143. instance.Email = response.result.emailAddress;
  144. instance.ContactNumber = response.result.phoneNumber;
  145. instance.UserName = response.result.unibaseId;
  146. instance.TenantId = response.result.tenantId;
  147. instance.ContactName = response.result.userName;
  148. $(".lbl_Otp").removeClass('text-danger text-success').text("We have sent OTP on your Mobile Number and Email !");
  149. $("#txt_Otp").val('');
  150. $("#div_ValidationSummary").empty();
  151. instance.sendOtp(0);
  152. }
  153. else {
  154. MessageHelper.Instance().showError(response.message, "div_ValidationSummary");
  155. }
  156. });
  157. }
  158. }
  159. sendOtp(IsResend) {
  160. var instance = this;
  161. $(".preloader-it").fadeIn();
  162. var postData = {
  163. ContactOrEmail: $("#txt_EmailorPhone").val(),
  164. FirstName: instance.ContactName,
  165. LastName: "",
  166. ContactNumber: "",
  167. Email: "",
  168. TenantName: "",
  169. IsSignup: false,
  170. IsForgotPswd: false,
  171. IsRegisterUser: true,
  172. UnibaseId: instance.UserName,
  173. OtpId: IsResend,
  174. UserOtp: ""
  175. };
  176. instance._accountManager.sendOtp(postData).then(function (response) {
  177. if (IsResend != 0) {
  178. $(".lbl_Otp").text("OTP has been Resent!").removeClass('text-danger', '').addClass('text-success', '');
  179. }
  180. if (response == 0) {
  181. $(".preloader-it").delay(200).fadeOut("slow");
  182. MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary');
  183. }
  184. else {
  185. instance.OtpId = response;
  186. $("#modal_Otp").modal("show");
  187. $(".preloader-it").delay(200).fadeOut("slow");
  188. }
  189. }, function () {
  190. $(".preloader-it").delay(200).fadeOut("slow");
  191. MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary');
  192. });
  193. }
  194. verifyOtp() {
  195. var instance = this;
  196. if ($("#txt_Otp").val() == "")
  197. $(".lbl_Otp").text("Please Enter OTP!").addClass('text-danger', '');
  198. else {
  199. var postData = {
  200. FirstName: "",
  201. LastName: "",
  202. ContactNumber: "",
  203. Email: "",
  204. TenantName: "",
  205. ContactOrEmail: "",
  206. IsForgotPswd: false,
  207. IsRegisterUser: false,
  208. IsSignup: true,
  209. UnibaseId: "",
  210. OtpId: instance.OtpId,
  211. UserOtp: $("#txt_Otp").val(),
  212. };
  213. instance._accountManager.verifyOtp(postData).then(function (response) {
  214. if (response.code.toString() == "2") {
  215. $(".preloader-it").delay(200).fadeOut("slow");
  216. $(".lbl_Otp").text("Otp Expired, Please click on Resend to get new OTP").addClass('text-danger', '');
  217. $("#txt_Otp").val('');
  218. }
  219. else if (response.result != null) {
  220. if (response.result.contactConfirmed == false && response.result.emailConfirmed == false) {
  221. $(".preloader-it").delay(200).fadeOut("slow");
  222. $(".lbl_Otp").text("Invalid OTP!").addClass('text-danger', '');
  223. $("#txt_Otp").text('');
  224. }
  225. else {
  226. $(".preloader-it").fadeIn();
  227. $("#div_RegisterUser").addClass('d-none');
  228. $("#modal_Otp").modal("hide");
  229. $(".preloader-it").delay(200).fadeOut("slow");
  230. $("#lbl_Email").text($("#txt_EmailorPhone").val());
  231. $("#div_CreatePswd").removeClass('d-none');
  232. }
  233. }
  234. });
  235. }
  236. }
  237. createPassword() {
  238. var instance = this;
  239. $("#div_ValidationSummary").empty();
  240. var confirmPassword = $("#txt_ConfirmPswd").val();
  241. var password = $("#txt_NewPswd").val();
  242. if (password.length == 0 || confirmPassword.length == 0) {
  243. MessageHelper.Instance().showError("Password fields cannot be empty!", 'div_ValidationSummary');
  244. return false;
  245. }
  246. if (password.length < 8 || confirmPassword.length < 8) {
  247. MessageHelper.Instance().showError("Password must be atleast 8 characters!", 'div_ValidationSummary');
  248. return false;
  249. }
  250. if (password != confirmPassword) {
  251. MessageHelper.Instance().showError("New and Confirm Passwords doesn't match!", "div_ValidationSummary");
  252. return false;
  253. }
  254. var password = password;
  255. var decimal = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,15}$/;
  256. var checkpassword = password.match(decimal) ? true : false;
  257. if (checkpassword == false) {
  258. $(".pr-password").focus();
  259. MessageHelper.Instance().showError("Please Match the Password in requested Format", "div_ValidationSummary");
  260. return false;
  261. }
  262. var postData = {
  263. Password: $("#txt_NewPswd").val(),
  264. UserName: instance.UserName,
  265. Email: instance.Email,
  266. ContactNumber: instance.ContactNumber,
  267. TenantId: instance.TenantId,
  268. };
  269. instance._accountManager.registerUser(postData).then(function (response) {
  270. if (response.errors == null) {
  271. $("#div_CreatePswd").addClass('d-none');
  272. $("#div_SuccessMsg").removeClass('d-none');
  273. MessageHelper.Instance().showSuccess("Password Created Successfully", 'div_ValidationSummary');
  274. }
  275. else {
  276. $(".preloader-it").delay(200).fadeOut("slow");
  277. MessageHelper.Instance().showError(response.errors[0], "div_ValidationSummary");
  278. }
  279. });
  280. }
  281. submit() {
  282. }
  283. static Instance() {
  284. return new MobilNewRegisterUser();
  285. }
  286. }
  287. Components.MobilNewRegisterUser = MobilNewRegisterUser;
  288. })(Components = Compact.Components || (Compact.Components = {}));
  289. })(Compact = Themes.Compact || (Themes.Compact = {}));
  290. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  291. })(Unibase || (Unibase = {}));