Monorepo for Tangled
at 74318eac9fdd72cf69e916276814351931ed0dcb 117 lines 4.7 kB view raw
1{{ define "title" }} login {{ end }} 2 3{{ define "content" }} 4 {{ if .AddAccount }} 5 <div class="flex gap-2 my-4 bg-blue-50 dark:bg-blue-900/30 border border-blue-300 dark:border-sky-800 rounded px-3 py-2 text-blue-600 dark:text-blue-300"> 6 <span class="py-1">{{ i "user-plus" "w-4 h-4" }}</span> 7 <div> 8 <h5 class="font-medium">Add another account</h5> 9 <p class="text-sm">Sign in with a different account to add it to your account list.</p> 10 </div> 11 </div> 12 {{ end }} 13 14 {{ if and .LoggedInUser .LoggedInUser.Accounts }} 15 {{ $accounts := .LoggedInUser.Accounts }} 16 {{ if $accounts }} 17 <div class="my-4 border border-gray-200 dark:border-gray-700 rounded overflow-hidden"> 18 <div class="px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"> 19 <span class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Saved accounts</span> 20 </div> 21 <div class="divide-y divide-gray-200 dark:divide-gray-700"> 22 {{ range $accounts }} 23 <div class="flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700"> 24 <button 25 type="button" 26 hx-post="/account/switch" 27 hx-vals='{"did": "{{ .Did }}"}' 28 hx-swap="none" 29 class="flex items-center gap-2 flex-1 text-left min-w-0" 30 > 31 {{ template "user/fragments/pic" (list .Did "size-8") }} 32 <div class="flex flex-col min-w-0"> 33 <span class="text-sm font-medium dark:text-white truncate">{{ .Did | resolve | truncateAt30 }}</span> 34 <span class="text-xs text-gray-500 dark:text-gray-400">Click to switch</span> 35 </div> 36 </button> 37 <button 38 type="button" 39 hx-delete="/account/{{ .Did }}" 40 hx-swap="none" 41 class="p-1 text-gray-400 hover:text-red-500 dark:hover:text-red-400 flex-shrink-0" 42 title="Remove account" 43 > 44 {{ i "x" "w-4 h-4" }} 45 </button> 46 </div> 47 {{ end }} 48 </div> 49 </div> 50 {{ end }} 51 {{ end }} 52 53 <form 54 class="mt-4 group" 55 hx-post="/login" 56 hx-swap="none" 57 hx-disabled-elt="#login-button" 58 > 59 <div class="flex flex-col"> 60 <label for="handle">handle</label> 61 <input 62 autocapitalize="none" 63 autocorrect="off" 64 autocomplete="username" 65 type="text" 66 id="handle" 67 name="handle" 68 tabindex="1" 69 required 70 placeholder="akshay.tngl.sh" 71 /> 72 <span class="text-sm text-gray-500 mt-1"> 73 Use your <a href="https://atproto.com">AT Protocol</a> 74 handle to log in. If you're unsure, this is likely 75 your Tangled (<code>.tngl.sh</code>) or <a href="https://bsky.app">Bluesky</a> (<code>.bsky.social</code>) account. 76 </span> 77 </div> 78 <input type="hidden" name="return_url" value="{{ .ReturnUrl }}"> 79 <input type="hidden" name="add_account" value="{{ if .AddAccount }}true{{ end }}"> 80 81 <button 82 class="btn w-full my-2 mt-6 text-base" 83 type="submit" 84 id="login-button" 85 tabindex="3" 86 > 87 {{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }} 88 <span class="inline group-[.htmx-request]:hidden">login</span> 89 </button> 90 </form> 91 {{ if .ErrorCode }} 92 <div class="flex gap-2 my-2 bg-red-50 dark:bg-red-900 border border-red-500 rounded drop-shadow-sm px-3 py-2 text-red-500 dark:text-red-300"> 93 <span class="py-1">{{ i "circle-alert" "w-4 h-4" }}</span> 94 <div> 95 <h5 class="font-medium">Login error</h5> 96 <p class="text-sm"> 97 {{ if eq .ErrorCode "access_denied" }} 98 You have not authorized the app. 99 {{ else if eq .ErrorCode "session" }} 100 Server failed to create user session. 101 {{ else if eq .ErrorCode "max_accounts" }} 102 You have reached the maximum of 20 linked accounts. Please remove an account before adding a new one. 103 {{ else }} 104 Internal Server error. 105 {{ end }} 106 Please try again. 107 </p> 108 </div> 109 </div> 110 {{ end }} 111 <p class="text-sm text-gray-500"> 112 Don't have an account? <a href="/signup" class="underline">Create an account</a> on Tangled now! 113 </p> 114 115 <p id="login-msg" class="error w-full"></p> 116{{ end }} 117