credentials.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {{template "base" .}}
  2. {{define "title"}}{{.Title}}{{end}}
  3. {{define "page_body"}}
  4. <div class="card shadow mb-4">
  5. <div class="card-header py-3">
  6. <h6 class="m-0 font-weight-bold text-primary">Change password</h6>
  7. </div>
  8. <div class="card-body">
  9. {{if .PwdError}}
  10. <div class="card mb-4 border-left-warning">
  11. <div class="card-body text-form-error">{{.PwdError}}</div>
  12. </div>
  13. {{end}}
  14. <form id="user_form" action="{{.ChangePwdURL}}" method="POST" autocomplete="off">
  15. <div class="form-group row">
  16. <label for="idCurrentPassword" class="col-sm-2 col-form-label">Current password</label>
  17. <div class="col-sm-10">
  18. <input type="password" class="form-control" id="idCurrentPassword" name="current_password" required>
  19. </div>
  20. </div>
  21. <div class="form-group row">
  22. <label for="idNewPassword1" class="col-sm-2 col-form-label">New password</label>
  23. <div class="col-sm-10">
  24. <input type="password" class="form-control" id="idNewPassword1" name="new_password1" required>
  25. </div>
  26. </div>
  27. <div class="form-group row">
  28. <label for="idNewPassword2" class="col-sm-2 col-form-label">Confirm password</label>
  29. <div class="col-sm-10">
  30. <input type="password" class="form-control" id="idNewPassword2" name="new_password2" required>
  31. </div>
  32. </div>
  33. <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
  34. <button type="submit" class="btn btn-primary float-right mt-3 px-5 px-3">Change my password</button>
  35. </form>
  36. </div>
  37. </div>
  38. {{if .LoggedUser.CanManagePublicKeys}}
  39. <div class="card shadow mb-4">
  40. <div class="card-header py-3">
  41. <h6 class="m-0 font-weight-bold text-primary">Manage public keys</h6>
  42. </div>
  43. <div class="card-body">
  44. {{if .KeyError}}
  45. <div class="card mb-4 border-left-warning">
  46. <div class="card-body text-form-error">{{.KeyError}}</div>
  47. </div>
  48. {{end}}
  49. <form id="key_form" action="{{.ManageKeysURL}}" method="POST">
  50. <div class="form-group row">
  51. <div class="col-md-12 form_field_pk_outer">
  52. {{range $idx, $val := .PublicKeys}}
  53. <div class="row form_field_pk_outer_row">
  54. <div class="form-group col-md-11">
  55. <textarea class="form-control" id="idPublicKey{{$idx}}" name="public_keys" rows="4"
  56. placeholder="Paste your public key here">{{$val}}</textarea>
  57. </div>
  58. <div class="form-group col-md-1">
  59. <button class="btn btn-circle btn-danger remove_pk_btn_frm_field">
  60. <i class="fas fa-trash"></i>
  61. </button>
  62. </div>
  63. </div>
  64. {{else}}
  65. <div class="row form_field_pk_outer_row">
  66. <div class="form-group col-md-11">
  67. <textarea class="form-control" id="idPublicKey0" name="public_keys" rows="4"
  68. placeholder="Paste your public key here"></textarea>
  69. </div>
  70. <div class="form-group col-md-1">
  71. <button class="btn btn-circle btn-danger remove_pk_btn_frm_field" disabled>
  72. <i class="fas fa-trash"></i>
  73. </button>
  74. </div>
  75. </div>
  76. {{end}}
  77. </div>
  78. </div>
  79. <div class="row mx-1">
  80. <button type="button" class="btn btn-secondary add_new_pk_field_btn">
  81. <i class="fas fa-plus"></i> Add new public key
  82. </button>
  83. </div>
  84. <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
  85. <button type="submit" class="btn btn-primary float-right mt-3 px-5 px-3">Submit</button>
  86. </form>
  87. </div>
  88. </div>
  89. {{end}}
  90. <div class="card shadow mb-4">
  91. <div class="card-header py-3">
  92. <h6 class="m-0 font-weight-bold text-primary">REST API access</h6>
  93. </div>
  94. <div class="card-body">
  95. {{if .APIKeyError}}
  96. <div class="card mb-4 border-left-warning">
  97. <div class="card-body text-form-error">{{.APIKeyError}}</div>
  98. </div>
  99. {{end}}
  100. <form id="key_form" action="{{.ManageAPIKeyURL}}" method="POST">
  101. <div class="form-group">
  102. <div class="form-check">
  103. <input type="checkbox" class="form-check-input" id="idAllowAPIKeyAuth" name="allow_api_key_auth"
  104. {{if .AllowAPIKeyAuth}}checked{{end}} aria-describedby="allowAPIKeyAuthHelpBlock">
  105. <label for="idAllowAPIKeyAuth" class="form-check-label">Allow API key authentication</label>
  106. <small id="allowAPIKeyAuthHelpBlock" class="form-text text-muted">
  107. Allow to impersonate yourself, in REST API, with an API key. If this permission is not granted, your credentials are required to use the REST API on your behalf
  108. </small>
  109. </div>
  110. </div>
  111. <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
  112. <button type="submit" class="btn btn-primary float-right mt-3 px-5 px-3">Submit</button>
  113. </form>
  114. </div>
  115. </div>
  116. {{end}}
  117. {{define "extra_js"}}
  118. <script type="text/javascript">
  119. $(document).ready(function () {
  120. $("body").on("click", ".add_new_pk_field_btn", function () {
  121. var index = $(".form_field_pk_outer").find(".form_field_pk_outer_row").length;
  122. while (document.getElementById("idPublicKey"+index) != null){
  123. index++;
  124. }
  125. $(".form_field_pk_outer").append(`
  126. <div class="row form_field_pk_outer_row">
  127. <div class="form-group col-md-11">
  128. <textarea class="form-control" id="idPublicKey${index}" name="public_keys" rows="4"
  129. placeholder="Paste your public key here"></textarea>
  130. </div>
  131. <div class="form-group col-md-1">
  132. <button class="btn btn-circle btn-danger remove_pk_btn_frm_field">
  133. <i class="fas fa-trash"></i>
  134. </button>
  135. </div>
  136. </div>
  137. `);
  138. });
  139. $("body").on("click", ".remove_pk_btn_frm_field", function () {
  140. $(this).closest(".form_field_pk_outer_row").remove();
  141. });
  142. });
  143. </script>
  144. {{end}}