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.

317 lines
12 KiB

9 years ago
9 years ago
  1. {% extends "base.html" %}
  2. {% load compress static hc_extras %}
  3. {% block title %}Account Settings - {{ site_name }}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1 class="settings-title">
  8. Settings
  9. <small>{{ request.user.email }}</small>
  10. </h1>
  11. </div>
  12. {% if messages %}
  13. <div class="col-sm-12">
  14. {% for message in messages %}
  15. <p class="alert alert-{{ message.tags }}">{{ message }}</p>
  16. {% endfor %}
  17. </div>
  18. {% endif %}
  19. </div>
  20. <div class="row">
  21. <div class="col-sm-3">
  22. <ul class="nav nav-pills nav-stacked">
  23. <li class="active"><a href="{% url 'hc-profile' %}">Account</a></li>
  24. <li><a href="{% url 'hc-appearance' %}">Appearance</a></li>
  25. {% if show_pricing %}
  26. <li><a href="{% url 'hc-billing' %}">Billing</a></li>
  27. {% endif %}
  28. <li><a href="{% url 'hc-notifications' %}">Email Reports</a></li>
  29. </ul>
  30. </div>
  31. <div class="col-sm-9 col-md-6">
  32. <div class="panel panel-{{ email_password_status|default:'default' }}">
  33. <div class="panel-body settings-block">
  34. <form method="post">
  35. {% csrf_token %}
  36. <h2>Email and Password</h2>
  37. <p class="settings-bar">
  38. Your account's email address is
  39. <code>{{ request.user.email }}</code>
  40. <a
  41. href="{% url 'hc-change-email' %}"
  42. class="btn btn-default pull-right">Change Email</a>
  43. </p>
  44. <p class="clearfix"></p>
  45. {% if request.user.has_usable_password %}
  46. <p class="settings-bar">
  47. Password authentication is enabled.
  48. <a
  49. href="{% url 'hc-set-password' %}"
  50. class="btn btn-default pull-right">Change Password</a>
  51. </p>
  52. {% else %}
  53. <p class="settings-bar">
  54. Attach a password to your {{ site_name }} account.
  55. <a
  56. href="{% url 'hc-set-password' %}"
  57. class="btn btn-default pull-right">Set Password</a>
  58. </p>
  59. {% endif %}
  60. </form>
  61. </div>
  62. {% if changed_password %}
  63. <div class="panel-footer">
  64. Your new password has been set!
  65. </div>
  66. {% endif %}
  67. </div>
  68. <div class="panel panel-{{ 2fa_status }}">
  69. <div class="panel-body settings-block">
  70. <form method="post">
  71. {% csrf_token %}
  72. <h2>Two-factor Authentication</h2>
  73. <table id="my-keys" class="table">
  74. {% if use_webauthn %}
  75. <tr>
  76. <th>Security keys</th>
  77. <th></th>
  78. </tr>
  79. {% for credential in credentials %}
  80. <tr>
  81. <td>
  82. {{ credential.name|default:"unnamed" }}
  83. <span class="text-muted">
  84. – registered on {{ credential.created|date:"M j, Y" }}
  85. </span>
  86. </td>
  87. <td class="text-right">
  88. <a href="{% url 'hc-remove-credential' credential.code %}">Remove</a>
  89. </td>
  90. </tr>
  91. {% empty %}
  92. <tr>
  93. <td class="missing" colspan="2">No registered security keys</td>
  94. </tr>
  95. {% endfor %}
  96. {% endif %}
  97. <tr>
  98. <th>Authenticator app</th>
  99. <th></th>
  100. </tr>
  101. {% if profile.totp %}
  102. <tr>
  103. <td>
  104. Enabled
  105. <span class="text-muted">
  106. – configured on {{ profile.totp_created|date:"M j, Y" }}
  107. </span>
  108. </td>
  109. <td class="text-right">
  110. <a href="{% url 'hc-remove-totp' %}">Remove</a>
  111. </td>
  112. </tr>
  113. {% else %}
  114. <tr>
  115. <td class="missing" colspan="2">Not configured</td>
  116. </tr>
  117. {% endif %}
  118. </table>
  119. {% if credentials|length == 1 %}
  120. <p class="alert alert-info">
  121. <strong>Tip: add a second security key!</strong>
  122. It is a good practice to register at least two security keys
  123. and store them separately.
  124. </p>
  125. {% endif %}
  126. {% if not credentials and not profile.totp %}
  127. <p class="alert alert-info">
  128. Two-factor authentication is currently <strong>inactive</strong>.
  129. Your account does not have any configured two-factor authentication
  130. methods.
  131. </p>
  132. {% endif %}
  133. <div class="pull-right">
  134. {% if not profile.totp %}
  135. <a
  136. href="{% url 'hc-add-totp' %}"
  137. class="btn btn-default">
  138. Set Up Authenticator App
  139. </a>
  140. {% endif %}
  141. {% if use_webauthn %}
  142. <a
  143. href="{% url 'hc-add-webauthn' %}"
  144. class="btn btn-default">
  145. Add Security Key
  146. </a>
  147. {% endif %}
  148. </div>
  149. </form>
  150. </div>
  151. {% if added_credential_name %}
  152. <div class="panel-footer">
  153. Added security key <strong>{{ added_credential_name }}</strong>.
  154. </div>
  155. {% endif %}
  156. {% if removed_credential_name %}
  157. <div class="panel-footer">
  158. Removed security key <strong>{{ removed_credential_name }}</strong>.
  159. </div>
  160. {% endif %}
  161. {% if enabled_totp %}
  162. <div class="panel-footer">
  163. Successfully set up the Authenticator app.
  164. </div>
  165. {% endif %}
  166. {% if disabled_totp %}
  167. <div class="panel-footer">
  168. Disabled the authenticator app.
  169. </div>
  170. {% endif %}
  171. </div>
  172. <div class="panel panel-{{ my_projects_status }}">
  173. <div class="panel-body settings-block">
  174. {% csrf_token %}
  175. <h2>My Projects</h2>
  176. {% if profile.projects.exists %}
  177. <table id="my-projects" class="table">
  178. <tr>
  179. <th>Project</th>
  180. <th>My role</th>
  181. <th></th>
  182. </tr>
  183. {% for project in request.user.project_set.all %}
  184. <tr>
  185. <td>
  186. <div class="name">
  187. <a href="{% url 'hc-checks' project.code %}">
  188. {{ project }}
  189. </a>
  190. </div>
  191. </td>
  192. <td>Owner</td>
  193. <td>
  194. <a
  195. href="{% url 'hc-project-settings' project.code %}"
  196. class="pull-right">Settings</a>
  197. </td>
  198. </tr>
  199. {% endfor %}
  200. {% for m in request.user.memberships.all %}
  201. <tr>
  202. <td>
  203. <div class="name">
  204. <a href="{% url 'hc-checks' m.project.code %}">
  205. {{ m.project }}
  206. </a>
  207. </div>
  208. </td>
  209. <td>{{ m.get_role_display }}</td>
  210. <td>
  211. <a
  212. href="#"
  213. data-name="{{ m.project }}"
  214. data-code="{{ m.project.code }}"
  215. class="pull-right leave-project">Leave</a>
  216. </td>
  217. </tr>
  218. {% endfor %}
  219. </table>
  220. {% else %}
  221. <p>You do not have any projects. Create one!</p>
  222. {% endif %}
  223. <a
  224. id="create-project"
  225. href="#"
  226. class="btn btn-default pull-right"
  227. data-toggle="modal"
  228. data-target="#add-project-modal">Create a New Project</a>
  229. </div>
  230. {% if left_project %}
  231. <div class="panel-footer">
  232. Left project <strong>{{ left_project }}</strong>.
  233. </div>
  234. {% endif %}
  235. </div>
  236. <div class="panel panel-default">
  237. <div class="panel-body settings-block">
  238. {% csrf_token %}
  239. <h2>Close Account</h2>
  240. <p>This will permanently remove your {{ site_name }} account.</p>
  241. <div class="text-right">
  242. <a
  243. id="close-account"
  244. href="{% url 'hc-close' %}"
  245. class="btn btn-default">Close Account</a>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <div id="leave-project-modal" class="modal">
  252. <div class="modal-dialog">
  253. <form id="leave-project-form" method="post">
  254. {% csrf_token %}
  255. <div class="modal-content">
  256. <div class="modal-header">
  257. <button type="button" class="close" data-dismiss="modal">&times;</button>
  258. <h4>Leave This Project?</h4>
  259. </div>
  260. <div class="modal-body">
  261. <p>
  262. You are about to leave the project <strong id="leave-project-name"></strong>.
  263. You will lose access to its checks and integrations.
  264. </p>
  265. <p>Are you sure?</p>
  266. <input
  267. type="hidden"
  268. name="code"
  269. id="leave-project-code" />
  270. </div>
  271. <div class="modal-footer">
  272. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  273. <button
  274. type="submit"
  275. name="leave_project"
  276. class="btn btn-danger">Leave Project</button>
  277. </div>
  278. </div>
  279. </form>
  280. </div>
  281. </div>
  282. {% include "accounts/add_project_modal.html" %}
  283. {% endblock %}
  284. {% block scripts %}
  285. {% compress js %}
  286. <script src="{% static 'js/jquery-3.6.0.min.js' %}"></script>
  287. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  288. <script src="{% static 'js/add_project_modal.js' %}"></script>
  289. <script src="{% static 'js/profile.js' %}"></script>
  290. {% endcompress %}
  291. {% endblock %}