Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

defaultlogin.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 Login extends Unibase.Platform.Core.BaseComponent {
  10. jsFiles() {
  11. var jsfiles = ["platform/bundle/default.login.min.js"];
  12. return jsfiles;
  13. }
  14. cssFiles() {
  15. return [];
  16. }
  17. load(id, containerid, callback) {
  18. this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance();
  19. Unibase.Platform.Membership.Infos.Identity.setCurrentUser(null);
  20. var instance = this;
  21. jQuery(".preloader-it").delay(500).fadeOut("slow");
  22. jQuery("#external-container").delay(500).fadeIn("slow");
  23. jQuery("#bizgaze_body").css("background-color", "#f4f6f7");
  24. $("#InputEmail,#InputPassword").keypress(function (e) {
  25. if (e.which == 13)
  26. document.getElementById("BtnLogin").click();
  27. });
  28. $('#PasswordHide').click(function () {
  29. var input = $('#InputPassword');
  30. input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password');
  31. $('#PasswordHide').toggleClass('fa-eye-slash fa-eye');
  32. });
  33. $("#btnClearcache").click(function () {
  34. if (isMobileApp()) {
  35. Unibase.Platform.Helpers.MobileHelper.Instance().openSettings();
  36. }
  37. });
  38. jQuery("#InputEmail,#InputPassword").on("input", function () {
  39. let username = $("#InputEmail").val().toString().trim();
  40. let password = $("#InputPassword").val();
  41. let validData = true;
  42. if (username == '' || username == undefined || password == '' || password == undefined)
  43. validData = false;
  44. if (validData) {
  45. jQuery("#BtnLogin").removeClass("disabled");
  46. }
  47. else {
  48. jQuery("#BtnLogin").addClass("disabled");
  49. }
  50. });
  51. jQuery("#BtnLogin").click(function () {
  52. instance.validate();
  53. });
  54. if (callback != null) {
  55. callback();
  56. }
  57. jQuery("#btn_loginhelp").click(function () {
  58. var instance = this;
  59. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/support/components/loginhelp.component.js"], function () {
  60. Unibase.Platform.Helpers.NavigationHelper.Instance().popin(0, "external-form", Bizgaze.Apps.Support.Components.LoginHelp.Instance(), null);
  61. });
  62. });
  63. }
  64. loadDomainLogo(imagerurl) {
  65. if (imagerurl != null && imagerurl != undefined && imagerurl != "") {
  66. this.imageurl = imagerurl;
  67. }
  68. else {
  69. this.imageurl = "tenants/themes/compact/imgs/bg_1.png";
  70. }
  71. }
  72. validate(username, password, remember) {
  73. MessageHelper.Instance().hideMessage();
  74. if (!isMobileApp() || (username == undefined && password == undefined)) {
  75. username = $("#InputEmail").val().toString().trim();
  76. password = $("#InputPassword").val().toString();
  77. remember = $("#InputRemember").prop("checked");
  78. }
  79. else {
  80. remember = true;
  81. }
  82. let validData = true;
  83. if (username == '' || username == undefined || password == '' || password == undefined)
  84. validData = false;
  85. if (validData) {
  86. jQuery("#BtnLogin").addClass("disabled");
  87. jQuery("#BtnLogin").text("Validating");
  88. var request = new Unibase.Platform.Membership.Requests.Login(username, password, "", remember);
  89. if (this._accountManager == undefined) {
  90. this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance();
  91. }
  92. this._accountManager.validateLogin(request).then(function (response) {
  93. var identity = response.result;
  94. if (identity === null) {
  95. if (isMobileApp()) {
  96. Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials('', '');
  97. }
  98. MessageHelper.Instance().showError(response.message, 'validation-summary');
  99. jQuery("#BtnLogin").removeClass("disabled");
  100. jQuery("#BtnLogin").text("Login");
  101. }
  102. else {
  103. if (isMobileApp()) {
  104. Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials(username, password);
  105. Unibase.Platform.Helpers.MobileHelper.Instance().saveUserDevice(identity.sessionId);
  106. }
  107. Unibase.Platform.Membership.Infos.Identity.setCurrentUser(identity);
  108. window.location.href = '#/welcome';
  109. if (isMobileApp()) {
  110. Unibase.Platform.Helpers.MobileHelper.Instance().SendUserDetails(JSON.stringify(identity));
  111. }
  112. }
  113. });
  114. }
  115. else {
  116. if (isMobileApp()) {
  117. Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials('', '');
  118. Unibase.Platform.Helpers.MobileHelper.Instance().redirectToLogin();
  119. }
  120. MessageHelper.Instance().showError("Mandatory fields are missing", 'validation-summary');
  121. }
  122. }
  123. html(id, containerid) {
  124. if (jQuery("#external-form").length === 0) {
  125. var index = new Compact.Components.Index_Anonymous();
  126. index.init(null, this.imageurl);
  127. }
  128. const html = `<form id="Frm_Login" default="" data-validate="parsley" data-isdynamic="false"><h1 class="display-4 mb-10">Login</h1><p class="mb-30">Sign in to your account and enjoy unlimited perks.</p><div id="validation-summary"></div><div class="form-group"><input class="form-control" id="InputEmail" placeholder="Phone or Email" type="text"></div><div class="form-group mb-20"><input class="form-control" id="InputPassword" placeholder="Password" type="password" autocomplete="new-password"><span toggle="#InputPassword" id="PasswordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span></div><div class="input-group mb-20"><div class="custom-control custom-checkbox col-xs"><input class="custom-control-input" id="InputRemember" type="checkbox"><label class="custom-control-label font-14" for="InputRemember">Keep me logged in</label></div><div class="col-xs ml-auto"><p class="text-right"><a href="index.html#/forgotpassword">Forgot Password?</a></p></div></div><a class="btn btn-primary btn-block text-white disabled" id="BtnLogin">Login</a><div class="col-2 mt-5" id="btn_loginhelp"><a href="#" style="text-decoration:underline">Help</a></div></form><div class="option-sep">or</div><div class="row"><div class="text-center col-sm-6 pa-5">Already an existing user? <a href="index.html#/registeruser">Register</a></div><div class="text-center col-sm-6 pa-5">Don’t have an account yet? <a href="index.html#/createcustomer">Create a Contact</a></div><div class="text-center col-sm p-2"></div></div>`;
  129. return html;
  130. }
  131. static Instance() {
  132. return new Login();
  133. }
  134. }
  135. Components.Login = Login;
  136. })(Components = Compact.Components || (Compact.Components = {}));
  137. })(Compact = Themes.Compact || (Themes.Compact = {}));
  138. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  139. })(Unibase || (Unibase = {}));