You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
9.6 KiB

4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
  1. {% extends "bootstrap/base.html" %}
  2. {% block title %}Manage your Technical Incompetence account{% endblock %}
  3. {% block styles %}
  4. {{super()}}
  5. <link rel="stylesheet" href="{{url_for('static', filename='style.css')}}">
  6. {% endblock %}
  7. {% block navbar %}
  8. {% include "fragments/navbar.j2" %}
  9. {% endblock %}
  10. {% block content %}
  11. <iframe id="apps" src="https://technicalincompetence.club/frame" width="305" height="400" class="shadow-lg overlay-frame" style="display: none;"></iframe>
  12. <div id="overlay" style="display: none;" onclick="showApps();"></div>
  13. <div class="container" style="margin-top: 15px">
  14. <div id="success-alert" class="alert alert-success" role="alert" style="display: none;">
  15. This is a success alert—check it out!
  16. </div>
  17. <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;">
  18. This is a danger alert—check it out!
  19. </div>
  20. <form>
  21. <div class="row">
  22. <div class="col-lg-6" id="firstNameRow">
  23. <label for="formGroupExampleInput1">First name</label>
  24. <input id="firstName" type="text" class="form-control" placeholder="First name" value="{{ user['firstName'] }}">
  25. </div>
  26. <div class="col-lg-6">
  27. <label for="formGroupExampleInput2">Last name</label>
  28. <input id="lastName" type="text" class="form-control" placeholder="Last name" value="{{ user['lastName'] }}">
  29. </div>
  30. </div>
  31. <br>
  32. <button type="button" class="btn btn-primary" onclick="updateName();">Change Name</button>
  33. </form>
  34. <br><br>
  35. <form>
  36. <div class="row">
  37. <div class="col-lg-6" id="userNameRow">
  38. <label for="formGroupExampleInput3">Username</label>
  39. <input id="userName" type="text" class="form-control" placeholder="Username" value="{{ user['userName'] }}">
  40. <br>
  41. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#userNameWarningModal">Change Username</button>
  42. <br>
  43. </div>
  44. <div class="col-lg-6">
  45. <label for="formGroupExampleInput4">Email</label>
  46. <input id="email" type="email" class="form-control" placeholder="Email" value="{{ user['email'] }}">
  47. <br>
  48. <button type="button" class="btn btn-primary" onclick="updateEmail();">Change Email</button>
  49. <br>
  50. </div>
  51. </div>
  52. </form>
  53. <br><br>
  54. <form>
  55. <button id="passwordButton" type="button" class="btn btn-danger" data-toggle="modal" data-target="#passwordChangeModal">Change Password</button>
  56. </form>
  57. <br><br>
  58. <form class="text-center">
  59. <button id="premiumButton" type="button" class="btn btn-success" data-toggle="modal" data-target="#upgradeModal">Upgrade to Technical Incompetence+</button>
  60. </form>
  61. <br><br>
  62. </div>
  63. <div id="userNameWarningModal" class="modal fade" tabindex="-1" role="dialog">
  64. <div class="modal-dialog" role="document">
  65. <div class="modal-content">
  66. <div class="modal-header">
  67. <h5 class="modal-title">Warning</h5>
  68. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  69. <span aria-hidden="true">&times;</span>
  70. </button>
  71. </div>
  72. <div class="modal-body">
  73. <div id="username-alert" class="alert alert-danger" role="alert" style="display: none;">
  74. This is a danger alert—check it out!
  75. </div>
  76. <p>If you change your username, you will be logged out here and likely need to re-login in everywhere with your new username.</p>
  77. </div>
  78. <div class="modal-footer">
  79. <button type="button" class="btn btn-danger" onclick="updateUserName();">Save new username</button>
  80. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div id="passwordChangeModal" class="modal fade" tabindex="-1" role="dialog">
  86. <div class="modal-dialog" role="document">
  87. <div class="modal-content">
  88. <div class="modal-header">
  89. <h5 class="modal-title">Update Password</h5>
  90. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  91. <span aria-hidden="true">&times;</span>
  92. </button>
  93. </div>
  94. <div class="modal-body">
  95. <div id="password-alert" class="alert alert-danger" role="alert" style="display: none;">
  96. This is a danger alert—check it out!
  97. </div>
  98. <p>If you change your password, you will be logged out here and likely need to re-login in everywhere with your new password.</p>
  99. <form style="padding: .75rem 1.25rem;">
  100. <div class="row">
  101. <label for="formGroupExampleInput5">Current Password</label>
  102. <input id="currentPassword" type="password" class="form-control" placeholder="Current Password">
  103. </div>
  104. <br>
  105. <div class="row">
  106. <label for="formGroupExampleInput6">New Password</label>
  107. <input id="newPassword" type="password" class="form-control" placeholder="New Password">
  108. </div>
  109. <br>
  110. <div class="row">
  111. <label for="formGroupExampleInput6">Confirm New Password</label>
  112. <input id="confirmNewPassword" type="password" class="form-control" placeholder="Confirm New Password">
  113. </div>
  114. </form>
  115. </div>
  116. <div class="modal-footer">
  117. <button type="button" class="btn btn-danger" onclick="updatePassword();">Change Password</button>
  118. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <div id="upgradeModal" class="modal fade" tabindex="-1" role="dialog">
  124. <div class="modal-dialog" role="document">
  125. <div class="modal-content">
  126. <div class="modal-header">
  127. <h5 class="modal-title">Upgrade to Technical Incompetence+</h5>
  128. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  129. <span aria-hidden="true">&times;</span>
  130. </button>
  131. </div>
  132. <div class="modal-body">
  133. <p>Coming soon!</p>
  134. </div>
  135. <div class="modal-footer">
  136. <button type="button" class="btn btn-danger" disabled>Upgrade</button>
  137. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. {% endblock %}
  143. {% block scripts %}
  144. {{ super() }}
  145. <script>
  146. function updateEmail() {
  147. email = $('#email').val();
  148. if (email.trim().length === 0) {
  149. showError('Email is required');
  150. return false;
  151. }
  152. dn = '{{ user['dn'] }}';
  153. $.ajax({
  154. url: '/update/email',
  155. method: 'POST',
  156. data: { "email": email,
  157. "dn": dn },
  158. success: function(data) {
  159. if (data === 'Success')
  160. showSuccess('Email updated!');
  161. else
  162. showError(data);
  163. }
  164. });
  165. }
  166. function updateName() {
  167. first = $('#firstName').val();
  168. last = $('#lastName').val();
  169. if (first.trim().length === 0 || last.trim().length === 0) {
  170. showError('Both first and last name are required');
  171. return false;
  172. }
  173. dn = '{{ user['dn'] }}';
  174. $.ajax({
  175. url: '/update/name',
  176. method: 'POST',
  177. data: { "firstName": first,
  178. "lastName": last,
  179. "dn": dn },
  180. success: function(data) {
  181. if (data === 'Success')
  182. showSuccess('Name updated!');
  183. else
  184. showError(data);
  185. }
  186. });
  187. }
  188. function updateUserName() {
  189. user = $('#userName').val();
  190. if (user.trim().length === 0) {
  191. showUsernameError('Username is required');
  192. return false;
  193. }
  194. dn = '{{ user['dn'] }}';
  195. $.ajax({
  196. url: '/update/username',
  197. method: 'POST',
  198. data: { "userName": user,
  199. "dn": dn },
  200. success: function(data) {
  201. if (data === 'Success')
  202. window.location = window.location.origin + "/logout";
  203. else
  204. showUsernameError(data);
  205. }
  206. });
  207. }
  208. function updatePassword() {
  209. currentPassword = $('#currentPassword').val();
  210. newPassword = $('#newPassword').val();
  211. confirmPassword = $('#confirmNewPassword').val();
  212. dn = '{{ user['dn'] }}';
  213. $.ajax({
  214. url: '/update/password',
  215. method: 'POST',
  216. data: { "currentPassword": currentPassword,
  217. "newPassword": newPassword,
  218. "confirmPassword": confirmPassword,
  219. "dn": dn },
  220. success: function(data) {
  221. if (data === 'Success')
  222. window.location = window.location.origin + "/logout";
  223. else
  224. showPasswordError(data)
  225. }
  226. });
  227. }
  228. function showError(error) {
  229. hideSuccess();
  230. $('#error-alert').text(error);
  231. $('#error-alert').show();
  232. }
  233. function showPasswordError(error) {
  234. $('#password-alert').text(error);
  235. $('#password-alert').show();
  236. }
  237. function showUsernameError(error) {
  238. $('#username-alert').text(error);
  239. $('#username-alert').show();
  240. }
  241. function hideError() {
  242. $('#error-alert').hide();
  243. }
  244. function showSuccess(message) {
  245. hideError();
  246. $('#success-alert').text(message);
  247. $('#success-alert').show();
  248. }
  249. function hideSuccess() {
  250. $('#success-alert').hide();
  251. }
  252. function showApps () {
  253. $("#apps").toggle();
  254. $("#overlay").toggle();
  255. }
  256. </script>
  257. {% endblock %}