Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(
- function() {
- var triesbeforemsg = 0;
- var tries = 0;
- var password = "";
- var tmppassword = "";
- // Set the focus on the first input field
- $('form:first *:input[type!=hidden]:first').focus();
- // Handle press of enter. Could be handled by adding a hidden input submit but
- // this requires a lot of css tweaking to get it right since display:none does
- // not work on every browser. So go for the js way
- $('form input').keydown(function(e) {
- if(e.which == 13 || e.which == 10) {
- e.preventDefault();
- $("#sign-me-in").click();
- }
- });
- $("#sign-me-in").on("click", function () {
- $(this).text('Verifying');
- password = $("#srp_password")[0].value;
- tmppassword = password;
- //to get the legacy_salt & is not null, and confirm the username is adminusername, do migration
- var legacysalt = "";
- var aduser = "admin";
- if (("" != legacysalt) && (aduser == $("#srp_username")[0].value))
- {
- var hashObj = new jsSHA((legacysalt+tch.stringToHex(password)), "HEX");
- password = hashObj.getHash("SHA-1", "HEX");
- }
- var srp = new SRP();
- srp.success = function() {
- //when do migration the legacy_salt is null and current user is admin, do the reset pass operation
- if (("" != legacysalt) && (aduser == $("#srp_username")[0].value))
- {
- srp.generateSaltAndVerifierTheCallback($("#srp_username")[0].value, tmppassword, function(salt, verStr) {
- $.post("/login.lp", { CSRFtoken:$("meta[name=CSRFtoken]").attr("content"), salt:salt, verifier:verStr, resetpass:"1" },
- function reloadPage(){
- if (window.location.pathname.search(/\/login\.lp$/) == -1)
- window.location.reload();
- else
- window.location = "/";
- });
- });
- }
- else
- {
- if (window.location.pathname.search(/\/login\.lp$/) == -1)
- window.location.reload();
- else
- window.location = "/";
- }
- }
- srp.error_message = function() {
- $("#sign-me-in").text('Sign in');
- $("#erroruserpass").show();
- $(".control-group").addClass("error");
- tries++;
- if(triesbeforemsg > 0 && tries >= triesbeforemsg) {
- $("#defaultpassword").show();
- }
- }
- srp.identify("/authenticate", $("#srp_username")[0].value, password);
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement