Skip to content

Commit e990fbd

Browse files
committed
proof of concept login/create buttons
1 parent ad9e665 commit e990fbd

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

app/components/AuthModal.vue

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ const handleInput = ref('')
55
66
const { user, logout } = await useAtproto()
77
8+
async function handleBlueskySignIn() {
9+
await navigateTo(
10+
{
11+
path: '/api/auth/atproto',
12+
query: { handle: 'https://bsky.social' },
13+
},
14+
{ external: true },
15+
)
16+
}
17+
18+
async function handleCreateAccount() {
19+
await navigateTo(
20+
{
21+
path: '/api/auth/atproto',
22+
query: { handle: 'https://selfhosted.social', create: 'true' },
23+
},
24+
{ external: true },
25+
)
26+
}
27+
828
async function handleLogin() {
929
if (handleInput.value) {
1030
await navigateTo(
@@ -74,15 +94,17 @@ async function handleLogin() {
7494

7595
<!-- Disconnected state -->
7696
<form v-else class="space-y-4" @submit.prevent="handleLogin">
77-
<p class="text-sm text-fg-muted">Login with your Atmosphere account</p>
97+
<p class="text-sm text-fg-muted">
98+
Login with your Atmosphere account. The same one as Bluesky, Blacksky, or tangled
99+
</p>
78100

79101
<div class="space-y-3">
80102
<div>
81103
<label
82104
for="handle-input"
83105
class="block text-xs text-fg-subtle uppercase tracking-wider mb-1.5"
84106
>
85-
Internet Handle
107+
Handle
86108
</label>
87109
<input
88110
id="handle-input"
@@ -125,6 +147,27 @@ async function handleLogin() {
125147
>
126148
Login
127149
</button>
150+
<button
151+
type="button"
152+
@click="handleCreateAccount"
153+
class="w-full px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"
154+
>
155+
Create a new account
156+
</button>
157+
<hr />
158+
<button
159+
type="button"
160+
@click="handleBlueskySignIn"
161+
class="w-full px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 focus-visible:ring-offset-2 focus-visible:ring-offset-bg flex items-center justify-center gap-2"
162+
>
163+
Sign in with Bluesky
164+
<svg fill="none" viewBox="0 0 64 57" width="20" style="width: 20px">
165+
<path
166+
fill="#0F73FF"
167+
d="M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805ZM50.127 3.805C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745Z"
168+
></path>
169+
</svg>
170+
</button>
128171
</form>
129172
</div>
130173
</div>

server/api/auth/atproto.get.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default defineEventHandler(async event => {
2424

2525
if (!query.code) {
2626
const handle = query.handle?.toString()
27+
const create = query.create?.toString()
2728

2829
if (!handle) {
2930
throw createError({
@@ -32,7 +33,10 @@ export default defineEventHandler(async event => {
3233
})
3334
}
3435

35-
const redirectUrl = await atclient.authorize(handle, { scope })
36+
const redirectUrl = await atclient.authorize(handle, {
37+
scope,
38+
prompt: create ? 'create' : undefined,
39+
})
3640
return sendRedirect(event, redirectUrl.toString())
3741
}
3842

0 commit comments

Comments
 (0)