@@ -1,76 +1,83 @@ |
| 1 | 1 | {{ define "page" -}} |
| 2 | | -<section class="shithub-auth shithub-auth-wide"> |
| 3 | | - <h1>Personal access tokens</h1> |
| 4 | | - <p>Tokens authenticate API calls and git-over-HTTPS pushes. Use them with <code>Authorization: token <value></code> or as the password in HTTP Basic.</p> |
| 2 | +<div class="shithub-settings-page"> |
| 3 | + {{ template "settings-nav" . }} |
| 4 | + <div class="shithub-settings-content"> |
| 5 | + <h1>Personal access tokens</h1> |
| 6 | + <section class="shithub-settings-section"> |
| 7 | + <p>Tokens authenticate API calls and git-over-HTTPS pushes. Use them with <code>Authorization: token <value></code> or as the password in HTTP Basic.</p> |
| 5 | 8 | |
| 6 | | - {{ if .JustCreatedRaw }} |
| 7 | | - <div class="shithub-token-created" role="alert"> |
| 8 | | - <strong>Save this token now — it won't be shown again.</strong> |
| 9 | | - <pre><code>{{ .JustCreatedRaw }}</code></pre> |
| 10 | | - </div> |
| 11 | | - {{ end }} |
| 12 | | - |
| 13 | | - {{ if .Tokens }} |
| 14 | | - <ul class="shithub-token-list"> |
| 15 | | - {{ range .Tokens }} |
| 16 | | - <li class="shithub-token-row"> |
| 17 | | - <div> |
| 18 | | - <strong>{{ .Name }}</strong> |
| 19 | | - <span class="shithub-key-meta"> |
| 20 | | - {{ if .RevokedAt.Valid }}revoked{{ else if and .ExpiresAt.Valid (gt .ExpiresAt.Time.Unix 0) }}expires {{ .ExpiresAt.Time.Format "2006-01-02" }}{{ else }}no expiry{{ end }} |
| 21 | | - </span> |
| 22 | | - <code class="shithub-key-fp">{{ .TokenPrefix }}…</code> |
| 23 | | - <div class="shithub-token-scopes">{{ range .Scopes }}<span>{{ . }}</span>{{ end }}</div> |
| 24 | | - {{ if .LastUsedAt.Valid }}<span class="shithub-key-last">last used {{ .LastUsedAt.Time.Format "2006-01-02 15:04" }}</span>{{ end }} |
| 9 | + {{ if .JustCreatedRaw }} |
| 10 | + <div class="shithub-token-created" role="alert"> |
| 11 | + <strong>Save this token now — it won't be shown again.</strong> |
| 12 | + <pre><code>{{ .JustCreatedRaw }}</code></pre> |
| 25 | 13 | </div> |
| 26 | | - {{ if not .RevokedAt.Valid }} |
| 27 | | - <form method="POST" action="/settings/tokens/{{ .ID }}/revoke" novalidate> |
| 28 | | - <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}"> |
| 29 | | - <button type="submit" class="shithub-button shithub-button-danger">Revoke</button> |
| 30 | | - </form> |
| 31 | 14 | {{ end }} |
| 32 | | - </li> |
| 33 | | - {{ end }} |
| 34 | | - </ul> |
| 35 | | - {{ else }} |
| 36 | | - <p class="shithub-key-empty">No tokens yet.</p> |
| 37 | | - {{ end }} |
| 38 | 15 | |
| 39 | | - <h2>Create a token</h2> |
| 40 | | - {{ if not .RecentAuthOK }} |
| 41 | | - <p class="shithub-flash shithub-flash-error" role="alert"> |
| 42 | | - Confirm 2FA before creating a token. <a href="/login">Sign in again</a> with your authenticator code. |
| 43 | | - </p> |
| 44 | | - {{ end }} |
| 45 | | - {{ with .CreateError }}<p class="shithub-flash shithub-flash-error" role="alert">{{ . }}</p>{{ end }} |
| 46 | | - <form method="POST" action="/settings/tokens" novalidate> |
| 47 | | - <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 48 | | - <label> |
| 49 | | - <span>Name</span> |
| 50 | | - <input type="text" name="name" maxlength="80" required value="{{ .CreateName }}" placeholder="ci runner, laptop, …"> |
| 51 | | - </label> |
| 52 | | - <label> |
| 53 | | - <span>Expiry</span> |
| 54 | | - <select name="expires_in"> |
| 55 | | - <option value="90">90 days (recommended)</option> |
| 56 | | - <option value="30">30 days</option> |
| 57 | | - <option value="365">1 year</option> |
| 58 | | - <option value="">No expiry</option> |
| 59 | | - </select> |
| 60 | | - </label> |
| 61 | | - <fieldset class="shithub-token-scopes-pick"> |
| 62 | | - <legend>Scopes</legend> |
| 63 | | - {{ $picked := .CreateScopes }} |
| 64 | | - {{ range .AllScopes }} |
| 65 | | - {{ $s := . }} |
| 66 | | - <label> |
| 67 | | - <input type="checkbox" name="scopes" value="{{ . }}" |
| 68 | | - {{ range $picked }}{{ if eq . (printf "%s" $s) }}checked{{ end }}{{ end }}> |
| 69 | | - <code>{{ . }}</code> |
| 70 | | - </label> |
| 16 | + {{ if .Tokens }} |
| 17 | + <ul class="shithub-token-list"> |
| 18 | + {{ range .Tokens }} |
| 19 | + <li class="shithub-token-row"> |
| 20 | + <div> |
| 21 | + <strong>{{ .Name }}</strong> |
| 22 | + <span class="shithub-key-meta"> |
| 23 | + {{ if .RevokedAt.Valid }}revoked{{ else if and .ExpiresAt.Valid (gt .ExpiresAt.Time.Unix 0) }}expires {{ .ExpiresAt.Time.Format "2006-01-02" }}{{ else }}no expiry{{ end }} |
| 24 | + </span> |
| 25 | + <code class="shithub-key-fp">{{ .TokenPrefix }}…</code> |
| 26 | + <div class="shithub-token-scopes">{{ range .Scopes }}<span>{{ . }}</span>{{ end }}</div> |
| 27 | + {{ if .LastUsedAt.Valid }}<span class="shithub-key-last">last used {{ .LastUsedAt.Time.Format "2006-01-02 15:04" }}</span>{{ end }} |
| 28 | + </div> |
| 29 | + {{ if not .RevokedAt.Valid }} |
| 30 | + <form method="POST" action="/settings/tokens/{{ .ID }}/revoke" novalidate> |
| 31 | + <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}"> |
| 32 | + <button type="submit" class="shithub-button shithub-button-danger">Revoke</button> |
| 33 | + </form> |
| 34 | + {{ end }} |
| 35 | + </li> |
| 36 | + {{ end }} |
| 37 | + </ul> |
| 38 | + {{ else }} |
| 39 | + <p class="shithub-key-empty">No tokens yet.</p> |
| 71 | 40 | {{ end }} |
| 72 | | - </fieldset> |
| 73 | | - <button type="submit" class="shithub-button shithub-button-primary">Create token</button> |
| 74 | | - </form> |
| 75 | | -</section> |
| 41 | + </section> |
| 42 | + |
| 43 | + <section class="shithub-settings-section"> |
| 44 | + <h2>Create a token</h2> |
| 45 | + {{ if not .RecentAuthOK }} |
| 46 | + <p class="shithub-flash shithub-flash-error" role="alert"> |
| 47 | + Confirm 2FA before creating a token. <a href="/login">Sign in again</a> with your authenticator code. |
| 48 | + </p> |
| 49 | + {{ end }} |
| 50 | + {{ with .CreateError }}<p class="shithub-flash shithub-flash-error" role="alert">{{ . }}</p>{{ end }} |
| 51 | + <form method="POST" action="/settings/tokens" novalidate> |
| 52 | + <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 53 | + <label> |
| 54 | + <span>Name</span> |
| 55 | + <input type="text" name="name" maxlength="80" required value="{{ .CreateName }}" placeholder="ci runner, laptop, …"> |
| 56 | + </label> |
| 57 | + <label> |
| 58 | + <span>Expiry</span> |
| 59 | + <select name="expires_in"> |
| 60 | + <option value="90">90 days (recommended)</option> |
| 61 | + <option value="30">30 days</option> |
| 62 | + <option value="365">1 year</option> |
| 63 | + <option value="">No expiry</option> |
| 64 | + </select> |
| 65 | + </label> |
| 66 | + <fieldset class="shithub-token-scopes-pick"> |
| 67 | + <legend>Scopes</legend> |
| 68 | + {{ $picked := .CreateScopes }} |
| 69 | + {{ range .AllScopes }} |
| 70 | + {{ $s := . }} |
| 71 | + <label> |
| 72 | + <input type="checkbox" name="scopes" value="{{ . }}" |
| 73 | + {{ range $picked }}{{ if eq . (printf "%s" $s) }}checked{{ end }}{{ end }}> |
| 74 | + <code>{{ . }}</code> |
| 75 | + </label> |
| 76 | + {{ end }} |
| 77 | + </fieldset> |
| 78 | + <button type="submit" class="shithub-button shithub-button-primary">Create token</button> |
| 79 | + </form> |
| 80 | + </section> |
| 81 | + </div> |
| 82 | +</div> |
| 76 | 83 | {{- end }} |