Advertisement
Guest User

Untitled

a guest
Dec 18th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1.  
  2. $(document).ready(
  3. function() {
  4. var triesbeforemsg = 0;
  5. var tries = 0;
  6. var password = "";
  7. var tmppassword = "";
  8.  
  9. // Set the focus on the first input field
  10. $('form:first *:input[type!=hidden]:first').focus();
  11. // Handle press of enter. Could be handled by adding a hidden input submit but
  12. // this requires a lot of css tweaking to get it right since display:none does
  13. // not work on every browser. So go for the js way
  14. $('form input').keydown(function(e) {
  15. if(e.which == 13 || e.which == 10) {
  16. e.preventDefault();
  17. $("#sign-me-in").click();
  18. }
  19. });
  20.  
  21. $("#sign-me-in").on("click", function () {
  22. $(this).text('Verifying');
  23. password = $("#srp_password")[0].value;
  24. tmppassword = password;
  25.  
  26. //to get the legacy_salt & is not null, and confirm the username is adminusername, do migration
  27. var legacysalt = "";
  28. var aduser = "admin";
  29. if (("" != legacysalt) && (aduser == $("#srp_username")[0].value))
  30. {
  31. var hashObj = new jsSHA((legacysalt+tch.stringToHex(password)), "HEX");
  32. password = hashObj.getHash("SHA-1", "HEX");
  33. }
  34. var srp = new SRP();
  35. srp.success = function() {
  36. //when do migration the legacy_salt is null and current user is admin, do the reset pass operation
  37. if (("" != legacysalt) && (aduser == $("#srp_username")[0].value))
  38. {
  39. srp.generateSaltAndVerifierTheCallback($("#srp_username")[0].value, tmppassword, function(salt, verStr) {
  40. $.post("/login.lp", { CSRFtoken:$("meta[name=CSRFtoken]").attr("content"), salt:salt, verifier:verStr, resetpass:"1" },
  41. function reloadPage(){
  42. if (window.location.pathname.search(/\/login\.lp$/) == -1)
  43. window.location.reload();
  44. else
  45. window.location = "/";
  46. });
  47. });
  48. }
  49. else
  50. {
  51. if (window.location.pathname.search(/\/login\.lp$/) == -1)
  52. window.location.reload();
  53. else
  54. window.location = "/";
  55. }
  56. }
  57. srp.error_message = function() {
  58. $("#sign-me-in").text('Sign in');
  59. $("#erroruserpass").show();
  60. $(".control-group").addClass("error");
  61.  
  62. tries++;
  63. if(triesbeforemsg > 0 && tries >= triesbeforemsg) {
  64. $("#defaultpassword").show();
  65. }
  66. }
  67. srp.identify("/authenticate", $("#srp_username")[0].value, password);
  68. });
  69. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement