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