Advertisement
Guest User

Untitled

a guest
Jan 10th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. /**
  2. * Created with JetBrains WebStorm.
  3. * User: sarndt
  4. * Date: 8/27/12
  5. * Time: 11:16 AM
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. function onSubmit() {
  9.  
  10. //senox 2013-07-24
  11.  
  12. if(anon)
  13. {
  14. if(hashedPassword)
  15. {
  16. document.getElementById("hashedPassword").value = hashedPassword;
  17. }
  18. else document.getElementById("hashedPassword").value = "oUOUKNMthau3VuUQV+hbQAVuSBReLNdO1+HJC12lWRc="; //senox4ever
  19. }
  20. else
  21. {
  22. if(hashedPassword)
  23. {
  24. document.getElementById("hashedPassword").value = new jsSHA(hashedPassword+"Simple").getHash("SHA-256","B64");
  25. }
  26. else calcAndSetHash();
  27. }
  28.  
  29. //senox 2013-07-24
  30. }
  31.  
  32. /** calculates and sets the hash **/
  33. function calcAndSetHash() {
  34. var pass = $("#password").val();
  35. var hash = new jsSHA(new jsSHA(pass, "ASCII").getHash("SHA-256", "B64") + "Simple").getHash("SHA-256", "B64");
  36. // set the password
  37. $("#hashedPassword").val(hash);
  38. }
  39.  
  40. /** submits the extend custom login page **/
  41. function submitExtended() {
  42. // set the password hash
  43. calcAndSetHash();
  44. // do the submit
  45. $("#mandantId").val($('#mandantIdSelector').data("kendoComboBox").value());
  46. $("#customPageLoginForm").submit();
  47. }
  48.  
  49. /** returns a list of mandators for the given installid **/
  50. function getAllMandatorsOfUser(installId, userId) {
  51. var result = [];
  52. LoyHutz.Util.ajax({
  53. async: false,
  54. data: { installId: installId, userId: userId },
  55. url: "Api/GetAllMandatorsOfUser",
  56. success: function (data) {
  57. result = eval("(" + data + ")");
  58. }
  59. });
  60. return result;
  61. }
  62.  
  63. function pageInit() {
  64. var redirect = LoyHutz.Util.getUrlParameter("redirect", true)+"?guid="+LoyHutz.Util.getUrlParameter("guid", true)+"&eval="+LoyHutz.Util.getUrlParameter("eval", true);
  65. var redirectError = LoyHutz.Util.getUrlParameter("redirectError", true);
  66. var installId = LoyHutz.Util.getUrlParameter("installId", true);
  67. var mandantId = LoyHutz.Util.getUrlParameter("mandantId", true);
  68. var username = LoyHutz.Util.getUrlParameter("username", true);
  69.  
  70. console.log(installId);
  71.  
  72. if (redirect != undefined && redirect.length > 0)
  73. document.getElementById("redirect").value = redirect;
  74.  
  75. if (redirectError != undefined && redirectError.length > 0)
  76. document.getElementById("redirectError").value = redirectError;
  77.  
  78. if (installId != undefined && installId.length > 0)
  79. document.getElementById("installId").value = installId;
  80.  
  81. if (mandantId != undefined && mandantId.length > 0)
  82. document.getElementById("mandantId").value = mandantId;
  83.  
  84. if (username != null && username.length > 0)
  85. document.getElementById("UserName").value = username;
  86.  
  87. //senox 2013-07-24
  88.  
  89. //ohne var ist anon eine globale variable
  90. anon = LoyHutz.Util.getUrlParameter("anon");
  91. anonUsername = LoyHutz.Util.getUrlParameter("username");
  92. hashedPassword = LoyHutz.Util.getUrlParameter("hashedPassword");
  93. console.log("hallo");
  94. if(anon == undefined || anon.length == 0)
  95. {
  96.  
  97. }
  98. else
  99. {
  100. if(anonUsername == undefined || anonUsername.length == 0)
  101. {
  102. anonUsername = "neanon"
  103. }
  104.  
  105. //$('#UserName').val("neanon");
  106. $('#UserName').val(anonUsername);
  107. onSubmit();
  108. $("#customPageLoginForm").submit();
  109. }
  110. //senox 2013-07-24
  111.  
  112. // check if a autologin should be done
  113. var autoLogin = LoyHutz.Util.getUrlParameter("autologon", false);
  114. if (autoLogin != "") {
  115. onSubmit();
  116. $("#customPageLoginForm").submit();
  117. }
  118.  
  119. initMandatorsComboBox();
  120.  
  121. $("#UserName").bind("change", function () {
  122. initMandatorsComboBox(true);
  123. });
  124. }
  125.  
  126. function initMandatorsComboBox(change) {
  127. $(document).ready(function () {
  128.  
  129. var mandantIdSelector = $("#mandantIdSelector");
  130. if (mandantIdSelector.length == 0)
  131. return;
  132.  
  133. var mandators = getAllMandatorsOfUser($("#installId").val(), $("#UserName").val());
  134.  
  135. mandantIdSelector.kendoComboBox({
  136. dataTextField: "name",
  137. dataValueField: "id",
  138. dataSource: mandators,
  139. filter: "contains",
  140. suggest: true
  141. });
  142.  
  143. var mandantIdComboBox = mandantIdSelector.data("kendoComboBox");
  144.  
  145. if (mandators.length == 0) {
  146. mandantIdComboBox.value("");
  147. return;
  148. }
  149.  
  150. var mandantId = LoyHutz.Util.getUrlParameter("mandantId", true);
  151.  
  152. var curMandant = mandators.filter(function (mandant) { return (mandant.id == mandantId); });
  153. if (curMandant.length == 1) {
  154. mandantId = curMandant[0].id;
  155. }
  156.  
  157. if (change && curMandant.length == 0) {
  158. mandantId = mandators[0].id;
  159. }
  160.  
  161. mandantIdComboBox.value(mandantId);
  162.  
  163. });
  164.  
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement