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.
 
 
 
 
 

172 lines
5.8 KiB

  1. {{define "settings"}}
  2. {{template "header" .}}
  3. <style type="text/css">
  4. .option { margin: 2em 0em; }
  5. h3 { font-weight: normal; }
  6. .section p, .section label {
  7. font-size: 0.86em;
  8. }
  9. .oauth-provider img {
  10. max-height: 2.75em;
  11. vertical-align: middle;
  12. }
  13. </style>
  14. <div class="content-container snug">
  15. {{if .Silenced}}
  16. {{template "user-silenced"}}
  17. {{end}}
  18. <h1>{{if .IsLogOut}}Before you go...{{else}}Account Settings{{end}}</h1>
  19. {{if .Flashes}}<ul class="errors">
  20. {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
  21. </ul>{{end}}
  22. {{ if .IsLogOut }}
  23. <div class="alert info">
  24. <p class="introduction">Please add an <strong>email address</strong> and/or <strong>passphrase</strong> so you can log in again later.</p>
  25. </div>
  26. {{ else }}
  27. <div>
  28. <p>Change your account settings here.</p>
  29. </div>
  30. <form method="post" action="/api/me/self" autocomplete="false">
  31. <div class="option">
  32. <h3>Username</h3>
  33. <div class="section">
  34. <input type="text" name="username" value="{{.Username}}" tabindex="1" />
  35. <input type="submit" value="Update" style="margin-left: 1em;" />
  36. </div>
  37. </div>
  38. </form>
  39. {{ end }}
  40. {{if not .DisablePasswordAuth}}
  41. <form method="post" action="/api/me/self" autocomplete="false">
  42. <input type="hidden" name="logout" value="{{.IsLogOut}}" />
  43. <div class="option">
  44. <h3>Passphrase</h3>
  45. <div class="section">
  46. {{if and (not .HasPass) (not .IsLogOut)}}<div class="alert info"><p>Add a passphrase to easily log in to your account.</p></div>{{end}}
  47. {{if .HasPass}}<p>Current passphrase</p>
  48. <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>
  49. <p>New passphrase</p>
  50. {{end}}
  51. {{if .IsLogOut}}<input type="text" value="{{.Username}}" style="display:none" />{{end}}
  52. <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>
  53. </div>
  54. </div>
  55. <div class="option">
  56. <h3>Email</h3>
  57. <div class="section">
  58. {{if and (not .Email) (not .IsLogOut)}}<div class="alert info"><p>Add your email to get:</p>
  59. <ul>
  60. <li>No-passphrase login</li>
  61. <li>Account recovery if you forget your passphrase</li>
  62. </ul></div>{{end}}
  63. <input type="email" name="email" style="letter-spacing: 1px" placeholder="Email address" value="{{.Email}}" size="40" tabindex="{{if .IsLogOut}}2{{else}}3{{end}}" />
  64. </div>
  65. </div>
  66. <div class="option" style="text-align: center;">
  67. <input type="submit" value="Save changes" tabindex="4" />
  68. </div>
  69. </form>
  70. {{end}}
  71. {{ if .OauthSection }}
  72. <hr />
  73. {{ if .OauthAccounts }}
  74. <div class="option">
  75. <h2>Linked Accounts</h2>
  76. <p>These are your linked external accounts.</p>
  77. {{ range $oauth_account := .OauthAccounts }}
  78. <form method="post" action="/api/me/oauth/remove" autocomplete="false">
  79. <input type="hidden" name="provider" value="{{ $oauth_account.Provider }}" />
  80. <input type="hidden" name="client_id" value="{{ $oauth_account.ClientID }}" />
  81. <input type="hidden" name="remote_user_id" value="{{ $oauth_account.RemoteUserID }}" />
  82. <div class="section oauth-provider">
  83. {{ if $oauth_account.DisplayName}}
  84. {{ if $oauth_account.AllowDisconnect}}
  85. <input type="submit" value="Remove {{.DisplayName}}" />
  86. {{else}}
  87. <a class="btn cta"><strong>{{.DisplayName}}</strong></a>
  88. {{end}}
  89. {{else}}
  90. <img src="/img/mark/{{$oauth_account.Provider}}.png" alt="{{ $oauth_account.Provider | title }}" />
  91. <input type="submit" value="Remove {{ $oauth_account.Provider | title }}" />
  92. {{end}}
  93. </div>
  94. </form>
  95. {{ end }}
  96. </div>
  97. {{ end }}
  98. {{ if or .OauthSlack .OauthWriteAs .OauthGitLab .OauthGeneric .OauthGitea }}
  99. <div class="option">
  100. <h2>Link External Accounts</h2>
  101. <p>Connect additional accounts to enable logging in with those providers, instead of using your username and password.</p>
  102. <div class="row signinbtns">
  103. {{ if .OauthWriteAs }}
  104. <div class="section oauth-provider">
  105. <a class="btn cta loginbtn" id="writeas-login" href="/oauth/write.as?attach=t">
  106. <img src="/img/mark/writeas-white.png" alt="Write.as" />
  107. Link <strong>Write.as</strong>
  108. </a>
  109. </div>
  110. {{ end }}
  111. {{ if .OauthSlack }}
  112. <div class="section oauth-provider">
  113. <a class="btn cta loginbtn" id="slack-login" href="/oauth/slack?attach=t">
  114. <img src="/img/mark/slack.png" alt="Slack" />
  115. Link <strong>Slack</strong>
  116. </a>
  117. </div>
  118. {{ end }}
  119. {{ if .OauthGitLab }}
  120. <div class="section oauth-provider">
  121. <a class="btn cta loginbtn" id="gitlab-login" href="/oauth/gitlab?attach=t">
  122. <img src="/img/mark/gitlab.png" alt="GitLab" />
  123. Link <strong>{{.GitLabDisplayName}}</strong>
  124. </a>
  125. </div>
  126. {{ end }}
  127. {{ if .OauthGitea }}
  128. <div class="section oauth-provider">
  129. <a class="btn cta loginbtn" id="gitea-login" href="/oauth/gitea?attach=t">
  130. <img src="/img/mark/gitea.png" alt="Gitea" />
  131. Link <strong>{{.GiteaDisplayName}}</strong>
  132. </a>
  133. </div>
  134. {{ end }}
  135. {{ if .OauthGeneric }}
  136. <div class="section oauth-provider">
  137. <a class="btn cta loginbtn" id="generic-oauth-login" href="/oauth/generic?attach=t">
  138. Link <strong>{{ .OauthGenericDisplayName }}</strong>
  139. </a>
  140. </div>
  141. {{ end }}
  142. </div>
  143. </div>
  144. {{ end }}
  145. {{ end }}
  146. </div>
  147. <script>
  148. var showChecks = document.querySelectorAll('input.show');
  149. for (var i=0; i<showChecks.length; i++) {
  150. showChecks[i].addEventListener('click', function() {
  151. var prevEl = this.previousElementSibling;
  152. if (prevEl.type == "password") {
  153. prevEl.type = "text";
  154. } else {
  155. prevEl.type = "password";
  156. }
  157. });
  158. }
  159. </script>
  160. {{template "footer" .}}
  161. {{end}}