Guest User

login.min.js

a guest
Sep 5th, 2021
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.     var s = "loginCaptcha";
  3.     var e = "detailCaptcha";
  4.     var d = "loginPhoneCaptcha";
  5.     var r = "";
  6.     var c = $("#login-form");
  7.     var l = c.find("button.signin");
  8.     var o = $("#login-form-cn");
  9.     if (o.length) {
  10.         $("#phone-number").trigger("focus")
  11.     } else {
  12.         $("#email").trigger("focus")
  13.     }
  14.     if (navigator.userAgent.indexOf("CrOS") !== -1) {
  15.         if (navigator.managed && navigator.managed.getManagedConfiguration) {
  16.             var i = ["DisableGoogleLogin", "DisableFacebookLogin", "DisableAppleLogin", "DisableLoginWithSSO", "DisableLoginWithEmail", "ForceLoginWithSSO"];
  17.  
  18.             navigator.managed.getManagedConfiguration(i).then(function(w) {
  19.                 var z = $("#login-btn-group");
  20.                 var y = z.find(".ride-line");
  21.                 var v = z.find(".login-btn-sso");
  22.                 var t = z.find(".login-btn-apple");
  23.                 var x = z.find(".login-btn-google");
  24.                 var u = z.find(".login-btn-facebook");
  25.                 if (w) {
  26.                     if (w.DisableGoogleLogin && w.DisableFacebookLogin && w.DisableAppleLogin && w.DisableLoginWithEmail && w.DisableLoginWithSSO && !w.ForceLoginWithSSO) {
  27.                         $(".right-container").css({ display: "none" });
  28.                         $("#login_left_container").css({ display: "none" });
  29.                         $(".mini-layout-login-body").css({ display: "flex", "align-items": "center", "justify-content": "center", "background-color": "white", "min-height": "480px" });
  30.                         $("#disable_all_for_chrome_os").css({ display: "block" })
  31.                     } else {
  32.                         $(".right-container").css({ "min-height": "480px" });
  33.                         if (w.DisableGoogleLogin) {
  34.                             x.hide()
  35.                         }
  36.                         if (w.DisableFacebookLogin) {
  37.                             u.hide()
  38.                         }
  39.                         if (w.DisableAppleLogin) {
  40.                             t.hide()
  41.                         }
  42.                         if (w.DisableLoginWithEmail) {
  43.                             c.hide();
  44.                             y.hide();
  45.                             $(".right-container").css({ display: "flex", "align-items": "center" })
  46.                         }
  47.                         if (w.DisableLoginWithSSO && !w.ForceLoginWithSSO) {
  48.                             v.hide()
  49.                         }
  50.                     }
  51.                 }
  52.             })
  53.         }
  54.     }
  55.     $("#password").on("input", function() {
  56.         $(this).val($(this).val().trim())
  57.     });
  58.     $("#email").on("input", function() {
  59.         $(this).val($(this).val().trim())
  60.     });
  61.  
  62.  
  63. //// THIS IS TRIGGERED ON CLICKING SIGNIN BUTTON
  64.  
  65.  
  66.     l.on("click", function() {
  67.         c.find("span.help-block").remove();
  68.         c.find("div.has-error").removeClass("has-error");
  69.         var t = c.valid();
  70.         if (!t) {
  71.             c.find("div.has-error input").length && c.find("div.has-error input").eq(0).trigger("focus");
  72.             return
  73.         }
  74.         if (signinNeedCaptcha && newCaptcha.isReCaptcha) {
  75.             l.disableBtn();
  76.             window.setTimeout(function() { l.enableBtn() }, 3000);
  77.             newCaptcha.executeReCaptcha(s, n)
  78.         } else {
  79.             c.trigger("submit") //// HERE I CAN DIRECTLY SUMBIT THE FORUM
  80.         }
  81.     });
  82.  
  83.  
  84. /////////////////////////////////////////////////
  85.  
  86.  
  87.     var h = false;
  88.     var q = $("#email").hasClass("validator-cn");
  89.     $.validator.addMethod("email_or_phone_number", function(v, u) {
  90.             var t = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(v.trim());
  91.             if ($(u).hasClass("validator-cn")) {
  92.                 return this.optional(u) || /^\d{11}$/.test(v.trim()) || t
  93.             } else {
  94.                 return this.optional(u) || t
  95.             }
  96.         },
  97.         q ? $.i18n.get("user.common.email_phone_invalid") : $.i18n.get("user.common.email_invalid"));
  98.     c.validate({
  99.         rules: function() {
  100.             var t = newCaptcha.getValidationRules();
  101.             t.email = { required: true, email_or_phone_number: true };
  102.             t.password = { required: true };
  103.             return t
  104.         }(),
  105.         messages: {
  106.             email: {
  107.                 required: q ? $.i18n.get("user.common.email_phone_invalid") : $.i18n.get("user.common.email_required")
  108.             },
  109.             password: {
  110.                 required: $.i18n.get("user.login.enter_password")
  111.             }
  112.         },
  113.         submitHandler: function() {
  114.             n();
  115.             return false
  116.         }
  117.     });
  118.  
  119.     function n() {
  120.         r = $("#email").val();
  121.         var u = /^\d{11}$/.test(r.trim());
  122.         var t = {
  123.             email: $("#email").val(),
  124.             password: $("#password").val(),
  125.             keep_me_signin: $("#keep_me_signin").is(":checked"),
  126.             recaptcha_challenge_field: $("#recaptcha_challenge_field").val(),
  127.             recaptcha_response_field: $("#recaptcha_response_field").val(),
  128.             type: u ? 11 : weSnsType,
  129.             captcha: newCaptcha.getValue(s),
  130.             captchaName: newCaptcha.getCaptchaName(s)
  131.         };
  132.         if (isFromChromePWA) {
  133.             t.from = "pwa"
  134.         }
  135.         if (jQuery.cookie("_zm_fl") != "1") {
  136.             SB.post3({
  137.                 url: "/signin",
  138.                 data: t,
  139.                 crossDomain: !SB.isIELower,
  140.                 xhrFields: {
  141.                     withCredentials: true
  142.                 },
  143.                 success: function(v) {
  144.                     if ($.cookie("enable_new_user_group_not_now")) {
  145.                         $.cookie("enable_new_user_group_not_now", null, { path: "/", secure: true })
  146.                     }
  147.                     if (!navigator.cookieEnabled) {
  148.                         SB.alert($.i18n.get("user.login.enable_browser_cookie"))
  149.                     } else {
  150.                         var w = v.result;
  151.                         if (isFromChromePWA && w.indexOf("from=pwa") < 0) {
  152.                             if (w.indexOf("?") > 0) {
  153.                                 w += "&from=pwa"
  154.                             } else {
  155.                                 w += "?from=pwa"
  156.                             }
  157.                         }
  158.                         location.href = w
  159.                     }
  160.                 },
  161.                 error: function(C, y, A) {
  162.                     var B = $("#error_msg");
  163.                     B.removeClass("alert-success");
  164.                     B.addClass("alert-danger");
  165.                     if (C) {
  166.                         if (A === 1106) {
  167.                             var z = new Date();
  168.                             z.setTime(z.getTime() + 30 * 60 * 1000);
  169.                             $.cookie("_zm_ct_smart", "true", { expires: z, path: "/" });
  170.                             location.href = "/signin";
  171.                             return
  172.                         } else {
  173.                             if (A == 1002) {
  174.                                 var v = y.split("\r");
  175.                                 if (u) {
  176.                                     errorMsg = $.i18n.get("error.user.login_phone_failure_tip")
  177.                                 } else {
  178.                                     var x = $("#page_type");
  179.                                     if (x && x.val()) {
  180.                                         var w = x.val();
  181.                                         if (w === "oauth.login") {
  182.                                             errorMsg = $.i18n.get("error.user.login_failure")
  183.                                         }
  184.                                     } else {
  185.                                         errorMsg = $.i18n.get("error.user.login_failure_tip")
  186.                                     }
  187.                                 }
  188.                                 B.html(errorMsg).show()
  189.                             } else {
  190.                                 if (A == 2029) {
  191.                                     errorMsg = $.i18n.get("error.account.work_email_login_disabled");
  192.                                     B.html(errorMsg).show()
  193.                                 } else {
  194.                                     if (A == 1035) {
  195.                                         h = true;
  196.                                         var v = y.split("\r");
  197.                                         errorMsg = $.i18n.get("error.user.login_failure_not_activate");
  198.                                         B.html(errorMsg).show()
  199.                                     } else {
  200.                                         if (A == 213) {
  201.                                             errorMsg = $.i18n.get("error.user.is_clock_out_status");
  202.                                             B.html(errorMsg).show()
  203.                                         } else {
  204.                                             B.text(y).show()
  205.                                         }
  206.                                     }
  207.                                 }
  208.                             }
  209.                         }
  210.                         if (B.is(":visible")) {
  211.                             B.attr({
  212.                                 "aria-label": B.text(),
  213.                                 tabindex: -1
  214.                             });
  215.                             B.trigger("focus")
  216.                         }
  217.                         if (newCaptcha) {
  218.                             newCaptcha.refresh(s)
  219.                         }
  220.                     } else {
  221.                         B.empty().hide()
  222.                     }
  223.                 },
  224.                 btn: l,
  225.                 showBusy: true,
  226.                 busyNode: $(".busy")
  227.             })
  228.         }
  229.     }
  230.     c.find("[name=password],[name=captcha-text]").on("keyup", function(t) {
  231.         if (t.keyCode == 13) {
  232.             l.trigger("click")
  233.         }
  234.     });
  235.     o && $("#form-group-captcha input[name=captcha-text]").removeClass("required");
  236.     o && o.validate({
  237.         rules: {
  238.             phone_number: {
  239.                 required: true,
  240.                 rangelength: [11, 11],
  241.                 digits: true
  242.             },
  243.             code_number: {
  244.                 required: true
  245.             }
  246.         },
  247.         messages: {
  248.             phone_number: {
  249.                 required: $.i18n.get("phone_number_error"),
  250.                 rangelength: $.i18n.get("phone_number_digits_error"),
  251.                 digits: $.i18n.get("phone_number_digits")
  252.             },
  253.             code_number: {
  254.                 required: $.i18n.get("code_required")
  255.             }
  256.         },
  257.         submitHandler: function() {
  258.             var t = {
  259.                 pn: $("#phone-number").val(),
  260.                 smscode: $("#code-number").val()
  261.             };
  262.             SB.post3({
  263.                 url: "/signin/verify_sms",
  264.                 data: t,
  265.                 success: function(u) {
  266.                     SB.post3({
  267.                         url: "/signin/phone",
  268.                         data: {
  269.                             pn: $("#phone-number").val(),
  270.                             stype: 11,
  271.                             keep_me_signin: $("#keep_me_signin").is(":checked"),
  272.                             sms_token: u.result
  273.                         },
  274.                         success: function(v) {
  275.                             location.href = v.result
  276.                         },
  277.                         error: function(x, v, w) {
  278.                             if (x) {
  279.                                 $("#error_msg").removeClass("alert-success").addClass("alert-danger").text(v).show();
  280.                                 console.error(v, w)
  281.                             }
  282.                         }
  283.                     })
  284.                 },
  285.                 error: function(y, u, w) {
  286.                     var x = $("#error_msg");
  287.                     if (y) {
  288.                         var v = o.validate();
  289.                         if (w == 3084) {
  290.                             v.showErrors({
  291.                                 code_number: u
  292.                             })
  293.                         } else {
  294.                             if (w == 3085) {
  295.                                 v.showErrors({
  296.                                     code_number: u
  297.                                 })
  298.                             } else {
  299.                                 if (w == 3086) {
  300.                                     v.showErrors({
  301.                                         phone_number: u
  302.                                     })
  303.                                 } else {
  304.                                     x.removeClass("alert-success").addClass("alert-danger").text(u).show()
  305.                                 }
  306.                             }
  307.                         }
  308.                     } else {
  309.                         x.empty().hide()
  310.                     }
  311.                 },
  312.                 btnContainer: o,
  313.                 showBusy: true,
  314.                 busyNode: $(".busy")
  315.             });
  316.             return false
  317.         }
  318.     });
  319.     o && o.find("#code-number").on("keyup", function(t) {
  320.         if (t.keyCode == 13) {
  321.             o.trigger("submit")
  322.         }
  323.     });
  324.     $("#btn-get-code").on("click", function() {
  325.         $("#form-group-captcha input[name=captcha-text]").rules("add", {
  326.             required: true,
  327.             messages: {
  328.                 required: $.i18n.get("captcha.required")
  329.             }
  330.         });
  331.         var u = o.validate();
  332.         u.element("#login-form-cn input[name=captcha-text]");
  333.         u.element("#phone-number");
  334.         var t = false;
  335.         if ($("#phone-number").parent(".form-group").hasClass("has-error") || $("#form-group-captcha").hasClass("has-error")) {
  336.             t = true
  337.         }
  338.         if (t) {
  339.             return
  340.         }
  341.         $("#form-group-captcha input[name=captcha-text]").rules("remove", "required");
  342.         var v = this;
  343.         $(this).html('<i class="zm-icon-loading"></i>');
  344.         SB.post3({
  345.             url: "/signin/sendsms",
  346.             data: {
  347.                 pn: $("#phone-number").val().trim(),
  348.                 captcha: newCaptcha.getValue(d)
  349.             },
  350.             success: function(w) {
  351.                 if (typeof w === "string") {
  352.                     try {
  353.                         w = JSON.parse(w)
  354.                     } catch (x) {
  355.                         console.log(error)
  356.                     }
  357.                 }
  358.                 if (!w.status) {
  359.                     newCaptcha.refresh(d);
  360.                     $("input[name=captcha-text]", o).trigger("focus");
  361.                     $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
  362.                 } else {
  363.                     $("#code-number").trigger("focus");
  364.                     var y = 59;
  365.                     $("#btn-get-code").attr("disabled", true);
  366.                     var z = setInterval(function() {
  367.                         var A = $.i18n.get("resend_after", y);
  368.                         y--;
  369.                         $("#btn-get-code").text(A);
  370.                         if (y === -1) {
  371.                             clearInterval(z);
  372.                             $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
  373.                         }
  374.                     }, 1000)
  375.                 }
  376.             },
  377.             showBusy: false,
  378.             error: function(x, y, w) {
  379.                 if (x) {
  380.                     newCaptcha.refresh(d);
  381.                     $(v).text($.i18n.get("send_code"));
  382.                     if (w === 3086) {
  383.                         u.showErrors({ phone_number: y });
  384.                         $("#phone-number").trigger("focus")
  385.                     } else {
  386.                         if (w === 300) {
  387.                             u.showErrors({ "captcha-text": y });
  388.                             $("input[name=captcha-text]", o).trigger("focus")
  389.                         } else {
  390.                             if (x) {
  391.                                 $("#error_msg").text(y).show()
  392.                             }
  393.                         }
  394.                     }
  395.                     $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
  396.                 }
  397.             }
  398.         })
  399.     });
  400.     var a = $("#existed_email_work").val() === "true";
  401.     var p = $("#existed_email_gmail").val() === "true";
  402.     var k = $("#existed_email_facebook").val() === "true";
  403.     var f = $("#param_email").val();
  404.     var j = "";
  405.     if (a) {
  406.         $("#email").val(f);
  407.         j = $.i18n.get("user.login.with_work_mail", SB.htmlEncode(f))
  408.     } else {
  409.         if (p) {
  410.             j = $.i18n.get("user.login.with_gmail", SB.htmlEncode(f))
  411.         } else {
  412.             if (k) {
  413.                 j = $.i18n.get("user.login.with_facebook", SB.htmlEncode(f))
  414.             }
  415.         }
  416.     }
  417.     if (j) {
  418.         SB.showSuccessMsg(j, null, 120 * 1000, true)
  419.     }
  420.     var m = $("#confirmSendLoginDetailDialog");
  421.     var g = $("#sendLoginDetailMailForm");
  422.     $("#btnContinue").on("click", function() {
  423.         var t = g.valid();
  424.         if (!t) {
  425.             return
  426.         }
  427.         if (newCaptcha.isReCaptcha) {
  428.             newCaptcha.executeReCaptcha(e, b)
  429.         } else {
  430.             g.trigger("submit")
  431.         }
  432.     });
  433.     g.validate({
  434.         rules: newCaptcha.getValidationRules(),
  435.         errorPlacement: function(t, u) {
  436.             t.addClass("help-block");
  437.             newCaptcha.addErrorClass(u, t)
  438.         },
  439.         submitHandler: function() {
  440.             b();
  441.             return false
  442.         }
  443.     });
  444.  
  445.     function b() {
  446.         var t = {
  447.             email: r,
  448.             recaptcha: newCaptcha.getValue(e),
  449.             captchaName: newCaptcha.getCaptchaName(e),
  450.             fr: "login",
  451.             type: weSnsType
  452.         };
  453.         var u = "/sendLoginFailDetail";
  454.         if (h) {
  455.             u = "/user_activate"
  456.         }
  457.         SB.post3({
  458.             url: u,
  459.             data: t,
  460.             success: function(w) {
  461.                 $.modal.close();
  462.                 var x = $("#error_msg");
  463.                 var v = $.i18n.get("user.send_detail_success", r);
  464.                 x.removeClass("alert-danger");
  465.                 x.addClass("alert-success");
  466.                 x.text(v).show()
  467.             },
  468.             error: function(y, v, w) {
  469.                 var x = $("#error_sendmail_msg");
  470.                 if (y) {
  471.                     newCaptcha.refresh(e);
  472.                     x.text(v).show()
  473.                 } else {
  474.                     x.empty().hide()
  475.                 }
  476.             },
  477.             btnContainer: g,
  478.             showBusy: true
  479.         })
  480.     }
  481.  
  482.  
  483.  
  484.  
  485. /////////// THIS IS TRIGGERED WHEN THE POST REQUEST FAILS WITH HTTP 401 UNAUTHORIZED
  486.  
  487.  
  488.     $("#error_msg").on("click", "#sendDetailMailId", function() {
  489.         $.modal(m, $.extend({}, SB.MODAL_DEFAULTS, {
  490.             overlayId: "signin-email-dialog-overlay",
  491.             containerId: "signin-email-dialog-container",
  492.             persist: true,
  493.             minHeight: m.outerHeight(),
  494.             onShow: function() {
  495.                 if ($("#error_sendmail_msg").length) {
  496.                     $("#error_sendmail_msg").empty().hide()
  497.                 }
  498.                 newCaptcha.refresh(e)
  499.             },
  500.             onClose: function() {
  501.                 newCaptcha.refresh(s);
  502.                 $.modal.close()
  503.             }
  504.         }))
  505.  
  506. /////////////////////////////////////////////////////////////////////////////////////
  507.  
  508.  
  509.     })
  510. });
Advertisement
Add Comment
Please, Sign In to add comment