A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
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.
 
 
 
 
 

232 lines
7.8 KiB

  1. {{define "settings"}}
  2. {{template "header" .}}
  3. <style type="text/css">
  4. .option { margin: 2em 0em; }
  5. h2 {
  6. margin-top: 2.5em;
  7. }
  8. h3 { font-weight: normal; }
  9. .section p, .section label {
  10. font-size: 0.86em;
  11. }
  12. .oauth-provider img {
  13. max-height: 2.75em;
  14. vertical-align: middle;
  15. }
  16. .modal {
  17. position: fixed;
  18. }
  19. </style>
  20. <div class="content-container snug">
  21. <div id="overlay"></div>
  22. {{if .Silenced}}
  23. {{template "user-silenced"}}
  24. {{end}}
  25. <h1>{{if .IsLogOut}}Before you go...{{else}}Account Settings{{end}}</h1>
  26. {{if .Flashes}}<ul class="errors">
  27. {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
  28. </ul>{{end}}
  29. {{ if .IsLogOut }}
  30. <div class="alert info">
  31. <p class="introduction">Please add an <strong>email address</strong> and/or <strong>passphrase</strong> so you can log in again later.</p>
  32. </div>
  33. {{ else }}
  34. <div>
  35. <p>Change your account settings here.</p>
  36. </div>
  37. <form method="post" action="/api/me/self" autocomplete="false">
  38. <div class="option">
  39. <h3>Username</h3>
  40. <div class="section">
  41. <input type="text" name="username" value="{{.Username}}" tabindex="1" />
  42. <input type="submit" value="Update" style="margin-left: 1em;" />
  43. </div>
  44. </div>
  45. </form>
  46. {{ end }}
  47. {{if not .DisablePasswordAuth}}
  48. <form method="post" action="/api/me/self" autocomplete="false">
  49. <input type="hidden" name="logout" value="{{.IsLogOut}}" />
  50. <div class="option">
  51. <h3>Passphrase</h3>
  52. <div class="section">
  53. {{if and (not .HasPass) (not .IsLogOut)}}<div class="alert info"><p>Add a passphrase to easily log in to your account.</p></div>{{end}}
  54. {{if .HasPass}}<p>Current passphrase</p>
  55. <input type="password" name="current-pass" placeholder="Current passphrase" tabindex="1" /> <input class="show" type="checkbox" id="show-cur-pass" /><label for="show-cur-pass"> Show</label>
  56. <p>New passphrase</p>
  57. {{end}}
  58. {{if .IsLogOut}}<input type="text" value="{{.Username}}" style="display:none" />{{end}}
  59. <input type="password" name="new-pass" autocomplete="new-password" placeholder="New passphrase" tabindex="{{if .IsLogOut}}1{{else}}2{{end}}" /> <input class="show" type="checkbox" id="show-new-pass" /><label for="show-new-pass"> Show</label>
  60. </div>
  61. </div>
  62. <div class="option">
  63. <h3>Email</h3>
  64. <div class="section">
  65. {{if and (not .Email) (not .IsLogOut)}}<div class="alert info"><p>Add your email to get:</p>
  66. <ul>
  67. <li>No-passphrase login</li>
  68. <li>Account recovery if you forget your passphrase</li>
  69. </ul></div>{{end}}
  70. <input type="email" name="email" style="letter-spacing: 1px" placeholder="Email address" value="{{.Email}}" size="40" tabindex="{{if .IsLogOut}}2{{else}}3{{end}}" />
  71. </div>
  72. </div>
  73. <div class="option" style="text-align: center;">
  74. <input type="submit" value="Save changes" tabindex="4" />
  75. </div>
  76. </form>
  77. {{end}}
  78. {{ if .OauthSection }}
  79. {{ if .OauthAccounts }}
  80. <div class="option">
  81. <h2>Linked Accounts</h2>
  82. <p>These are your linked external accounts.</p>
  83. {{ range $oauth_account := .OauthAccounts }}
  84. <form method="post" action="/api/me/oauth/remove" autocomplete="false">
  85. <input type="hidden" name="provider" value="{{ $oauth_account.Provider }}" />
  86. <input type="hidden" name="client_id" value="{{ $oauth_account.ClientID }}" />
  87. <input type="hidden" name="remote_user_id" value="{{ $oauth_account.RemoteUserID }}" />
  88. <div class="section oauth-provider">
  89. {{ if $oauth_account.DisplayName}}
  90. {{ if $oauth_account.AllowDisconnect}}
  91. <input type="submit" value="Remove {{.DisplayName}}" />
  92. {{else}}
  93. <a class="btn cta"><strong>{{.DisplayName}}</strong></a>
  94. {{end}}
  95. {{else}}
  96. <img src="/img/mark/{{$oauth_account.Provider}}.png" alt="{{ $oauth_account.Provider | title }}" />
  97. <input type="submit" value="Remove {{ $oauth_account.Provider | title }}" />
  98. {{end}}
  99. </div>
  100. </form>
  101. {{ end }}
  102. </div>
  103. {{ end }}
  104. {{ if or .OauthSlack .OauthWriteAs .OauthGitLab .OauthGeneric .OauthGitea }}
  105. <div class="option">
  106. <h2>Link External Accounts</h2>
  107. <p>Connect additional accounts to enable logging in with those providers, instead of using your username and password.</p>
  108. <div class="row signinbtns">
  109. {{ if .OauthWriteAs }}
  110. <div class="section oauth-provider">
  111. <a class="btn cta loginbtn" id="writeas-login" href="/oauth/write.as?attach=t">
  112. <img src="/img/mark/writeas-white.png" alt="Write.as" />
  113. Link <strong>Write.as</strong>
  114. </a>
  115. </div>
  116. {{ end }}
  117. {{ if .OauthSlack }}
  118. <div class="section oauth-provider">
  119. <a class="btn cta loginbtn" id="slack-login" href="/oauth/slack?attach=t">
  120. <img src="/img/mark/slack.png" alt="Slack" />
  121. Link <strong>Slack</strong>
  122. </a>
  123. </div>
  124. {{ end }}
  125. {{ if .OauthGitLab }}
  126. <div class="section oauth-provider">
  127. <a class="btn cta loginbtn" id="gitlab-login" href="/oauth/gitlab?attach=t">
  128. <img src="/img/mark/gitlab.png" alt="GitLab" />
  129. Link <strong>{{.GitLabDisplayName}}</strong>
  130. </a>
  131. </div>
  132. {{ end }}
  133. {{ if .OauthGitea }}
  134. <div class="section oauth-provider">
  135. <a class="btn cta loginbtn" id="gitea-login" href="/oauth/gitea?attach=t">
  136. <img src="/img/mark/gitea.png" alt="Gitea" />
  137. Link <strong>{{.GiteaDisplayName}}</strong>
  138. </a>
  139. </div>
  140. {{ end }}
  141. {{ if .OauthGeneric }}
  142. <div class="section oauth-provider">
  143. <a class="btn cta loginbtn" id="generic-oauth-login" href="/oauth/generic?attach=t">
  144. Link <strong>{{ .OauthGenericDisplayName }}</strong>
  145. </a>
  146. </div>
  147. {{ end }}
  148. </div>
  149. </div>
  150. {{ end }}
  151. {{ end }}
  152. {{ if and .OpenDeletion (not .IsAdmin) }}
  153. <h2>Incinerator</h2>
  154. <div class="alert danger">
  155. <div class="row">
  156. <div>
  157. <h3>Delete your account</h3>
  158. <p>Permanently erase all your data, with no way to recover it.</p>
  159. </div>
  160. <button class="cta danger" onclick="prepareDeleteUser()">Delete your account...</button>
  161. </div>
  162. </div>
  163. {{end}}
  164. </div>
  165. <div id="modal-delete-user" class="modal">
  166. <h2>Are you sure?</h2>
  167. <div class="body">
  168. <p style="text-align:left">This action <strong>cannot</strong> be undone. It will immediately and permanently erase your account, including your blogs and posts. Before continuing, you might want to <a href="/me/export">export your data</a>.</p>
  169. <p>If you're sure, please type <strong>{{.Username}}</strong> to confirm.</p>
  170. <ul id="delete-errors" class="errors"></ul>
  171. <form action="/me/delete" method="post" onsubmit="confirmDeletion()">
  172. {{ .CSRFField }}
  173. <input id="confirm-text" placeholder="{{.Username}}" type="text" class="confirm boxy" name="confirm-username" style="margin-top: 0.5em;" />
  174. <div style="text-align:right; margin-top: 1em;">
  175. <a id="cancel-delete" style="margin-right:2em" href="#">Cancel</a>
  176. <input class="danger" type="submit" id="confirm-delete" value="Delete your account" disabled />
  177. </div>
  178. </div>
  179. </div>
  180. <script src="/js/h.js"></script>
  181. <script src="/js/modals.js"></script>
  182. <script>
  183. var showChecks = document.querySelectorAll('input.show');
  184. for (var i=0; i<showChecks.length; i++) {
  185. showChecks[i].addEventListener('click', function() {
  186. var prevEl = this.previousElementSibling;
  187. if (prevEl.type == "password") {
  188. prevEl.type = "text";
  189. } else {
  190. prevEl.type = "password";
  191. }
  192. });
  193. }
  194. {{ if and .OpenDeletion (not .IsAdmin) }}
  195. H.getEl('cancel-delete').on('click', closeModals);
  196. let $confirmDelBtn = document.getElementById('confirm-delete');
  197. let $confirmText = document.getElementById('confirm-text')
  198. $confirmText.addEventListener('input', function() {
  199. $confirmDelBtn.disabled = this.value !== '{{.Username}}'
  200. });
  201. function prepareDeleteUser() {
  202. $confirmText.value = ''
  203. showModal('delete-user')
  204. $confirmText.focus()
  205. }
  206. function confirmDeletion() {
  207. $confirmDelBtn.disabled = true
  208. $confirmDelBtn.value = 'Deleting...'
  209. }
  210. {{ end }}
  211. </script>
  212. {{template "footer" .}}
  213. {{end}}