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.

315 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. </tr>
  78. {% for credential in credentials %}
  79. <tr>
  80. <td>
  81. {{ credential.name|default:"unnamed" }}
  82. <span class="text-muted">
  83. – registered on {{ credential.created|date:"M j, Y" }}
  84. </span>
  85. </td>
  86. <td class="text-right">
  87. <a href="{% url 'hc-remove-credential' credential.code %}">Remove</a>
  88. </td>
  89. </tr>
  90. {% empty %}
  91. <tr>
  92. <td class="missing" colspan="2">No registered security keys</td>
  93. </tr>
  94. {% endfor %}
  95. {% endif %}
  96. <tr>
  97. <th>Authenticator app</th>
  98. </tr>
  99. {% if profile.totp %}
  100. <tr>
  101. <td>
  102. Enabled
  103. <span class="text-muted">
  104. – configured on {{ profile.totp_created|date:"M j, Y" }}
  105. </span>
  106. </td>
  107. <td class="text-right">
  108. <a href="{% url 'hc-remove-totp' %}">Remove</a>
  109. </td>
  110. </tr>
  111. {% else %}
  112. <tr>
  113. <td class="missing" colspan="2">Not configured</td>
  114. </tr>
  115. {% endif %}
  116. </table>
  117. {% if credentials|length == 1 %}
  118. <p class="alert alert-info">
  119. <strong>Tip: add a second security key!</strong>
  120. It is a good practice to register at least two security keys
  121. and store them separately.
  122. </p>
  123. {% endif %}
  124. {% if not credentials and not profile.totp %}
  125. <p class="alert alert-info">
  126. Two-factor authentication is currently <strong>inactive</strong>.
  127. Your account does not have any configured two-factor authentication
  128. methods.
  129. </p>
  130. {% endif %}
  131. <div class="pull-right">
  132. {% if not profile.totp %}
  133. <a
  134. href="{% url 'hc-add-totp' %}"
  135. class="btn btn-default">
  136. Set Up Authenticator App
  137. </a>
  138. {% endif %}
  139. {% if use_webauthn %}
  140. <a
  141. href="{% url 'hc-add-webauthn' %}"
  142. class="btn btn-default">
  143. Add Security Key
  144. </a>
  145. {% endif %}
  146. </div>
  147. </form>
  148. </div>
  149. {% if added_credential_name %}
  150. <div class="panel-footer">
  151. Added security key <strong>{{ added_credential_name }}</strong>.
  152. </div>
  153. {% endif %}
  154. {% if removed_credential_name %}
  155. <div class="panel-footer">
  156. Removed security key <strong>{{ removed_credential_name }}</strong>.
  157. </div>
  158. {% endif %}
  159. {% if enabled_totp %}
  160. <div class="panel-footer">
  161. Successfully set up the Authenticator app.
  162. </div>
  163. {% endif %}
  164. {% if disabled_totp %}
  165. <div class="panel-footer">
  166. Disabled the authenticator app.
  167. </div>
  168. {% endif %}
  169. </div>
  170. <div class="panel panel-{{ my_projects_status }}">
  171. <div class="panel-body settings-block">
  172. {% csrf_token %}
  173. <h2>My Projects</h2>
  174. {% if profile.projects.exists %}
  175. <table id="my-projects" class="table">
  176. <tr>
  177. <th>Project</th>
  178. <th>My role</th>
  179. <th></th>
  180. </tr>
  181. {% for project in request.user.project_set.all %}
  182. <tr>
  183. <td>
  184. <div class="name">
  185. <a href="{% url 'hc-checks' project.code %}">
  186. {{ project }}
  187. </a>
  188. </div>
  189. </td>
  190. <td>Owner</td>
  191. <td>
  192. <a
  193. href="{% url 'hc-project-settings' project.code %}"
  194. class="pull-right">Settings</a>
  195. </td>
  196. </tr>
  197. {% endfor %}
  198. {% for m in request.user.memberships.all %}
  199. <tr>
  200. <td>
  201. <div class="name">
  202. <a href="{% url 'hc-checks' m.project.code %}">
  203. {{ m.project }}
  204. </a>
  205. </div>
  206. </td>
  207. <td>{{ m.get_role_display }}</td>
  208. <td>
  209. <a
  210. href="#"
  211. data-name="{{ m.project }}"
  212. data-code="{{ m.project.code }}"
  213. class="pull-right leave-project">Leave</a>
  214. </td>
  215. </tr>
  216. {% endfor %}
  217. </table>
  218. {% else %}
  219. <p>You do not have any projects. Create one!</p>
  220. {% endif %}
  221. <a
  222. id="create-project"
  223. href="#"
  224. class="btn btn-default pull-right"
  225. data-toggle="modal"
  226. data-target="#add-project-modal">Create a New Project</a>
  227. </div>
  228. {% if left_project %}
  229. <div class="panel-footer">
  230. Left project <strong>{{ left_project }}</strong>.
  231. </div>
  232. {% endif %}
  233. </div>
  234. <div class="panel panel-default">
  235. <div class="panel-body settings-block">
  236. {% csrf_token %}
  237. <h2>Close Account</h2>
  238. <p>This will permanently remove your {{ site_name }} account.</p>
  239. <div class="text-right">
  240. <a
  241. id="close-account"
  242. href="{% url 'hc-close' %}"
  243. class="btn btn-default">Close Account</a>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. <div id="leave-project-modal" class="modal">
  250. <div class="modal-dialog">
  251. <form id="leave-project-form" method="post">
  252. {% csrf_token %}
  253. <div class="modal-content">
  254. <div class="modal-header">
  255. <button type="button" class="close" data-dismiss="modal">&times;</button>
  256. <h4>Leave This Project?</h4>
  257. </div>
  258. <div class="modal-body">
  259. <p>
  260. You are about to leave the project <strong id="leave-project-name"></strong>.
  261. You will lose access to its checks and integrations.
  262. </p>
  263. <p>Are you sure?</p>
  264. <input
  265. type="hidden"
  266. name="code"
  267. id="leave-project-code" />
  268. </div>
  269. <div class="modal-footer">
  270. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  271. <button
  272. type="submit"
  273. name="leave_project"
  274. class="btn btn-danger">Leave Project</button>
  275. </div>
  276. </div>
  277. </form>
  278. </div>
  279. </div>
  280. {% include "accounts/add_project_modal.html" %}
  281. {% endblock %}
  282. {% block scripts %}
  283. {% compress js %}
  284. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  285. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  286. <script src="{% static 'js/add_project_modal.js' %}"></script>
  287. <script src="{% static 'js/profile.js' %}"></script>
  288. {% endcompress %}
  289. {% endblock %}