Skip to content

Commit c118aaa

Browse files
authored
Merge pull request #40 from hackclub-community/17-account-settings-ui
Add account settings UI and some other improvements
2 parents 10ae4ce + 76ae0f9 commit c118aaa

26 files changed

Lines changed: 1162 additions & 107 deletions

bun.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"convex": "^1.32.0",
5656
"convex-svelte": "^0.0.12",
5757
"hotkeys-js": "^4.0.2",
58-
"mode-watcher": "^1.1.0"
58+
"mode-watcher": "^1.1.0",
59+
"ua-parser-js": "^2.0.9"
5960
}
6061
}

src/convex/auth.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ export const createAuthOptions = (ctx: GenericCtx<DataModel>) => {
2525
emailAndPassword: {
2626
enabled: false
2727
},
28+
account: {
29+
accountLinking: {
30+
allowDifferentEmails: true
31+
}
32+
},
33+
user: {
34+
changeEmail: {
35+
enabled: false
36+
},
37+
deleteUser: {
38+
enabled: true
39+
}
40+
},
41+
socialProviders: {
42+
github: {
43+
clientId: process.env.GITHUB_CLIENT_ID!,
44+
clientSecret: process.env.GITHUB_CLIENT_SECRET!
45+
},
46+
google: {
47+
clientId: process.env.GOOGLE_CLIENT_ID!,
48+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!
49+
}
50+
},
2851
plugins: [
2952
convex({ authConfig }),
3053
genericOAuth({

src/lib/components/login.svelte

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Button from './ui/button/button.svelte';
66
import { authClient } from '$lib/auth-client';
77
import { useAuth } from '@mmailaender/convex-better-auth-svelte/svelte';
8-
import { ArrowRight, ArrowRightIcon } from '@lucide/svelte';
8+
import { ArrowRight, ArrowRightIcon, LoaderCircle } from '@lucide/svelte';
99
import { toast } from 'svelte-sonner';
1010
import Label from './ui/label/label.svelte';
1111
import * as InputGroup from '$lib/components/ui/input-group/index.js';
@@ -47,49 +47,51 @@
4747
<Card.Title>Log in as an organizer</Card.Title>
4848
</Card.Header>
4949
<Card.Content class="space-y-8">
50-
<Button
51-
disabled={loading}
52-
onclick={async () => {
53-
loading = true;
54-
toast.promise(
55-
authClient.signIn
56-
.oauth2({
50+
{#if loading}
51+
<div class="flex min-h-32 flex-col items-center justify-center gap-3">
52+
<LoaderCircle class="size-5 animate-spin" />
53+
</div>
54+
{:else}
55+
<Button
56+
disabled={loading}
57+
onclick={async () => {
58+
loading = true;
59+
try {
60+
const { error } = await authClient.signIn.oauth2({
5761
providerId: 'hca',
5862
callbackURL: '/organizer'
59-
})
60-
.then(({ data, error }) => {
61-
if (error) {
62-
loading = false;
63-
throw error;
64-
}
65-
return data;
66-
}),
67-
{
68-
loading: 'Loading...',
69-
success: 'Redirecting...',
70-
error: 'Something went wrong'
63+
});
64+
if (error) {
65+
loading = false;
66+
toast.error('Something went wrong');
67+
}
68+
} catch {
69+
loading = false;
70+
toast.error('Something went wrong');
7171
}
72-
);
73-
}}>Continue with Hack Club</Button
74-
>
75-
<form class="flex w-full flex-col gap-2">
76-
<Label for="email-{id}">Email</Label>
77-
<InputGroup.Root class="w-full">
78-
<InputGroup.Input
79-
type="email"
80-
name="email"
81-
id="email-{id}"
82-
required
83-
placeholder="iwill@hackthisclub.com"
84-
/>
85-
<InputGroup.Addon align="inline-end">
86-
<InputGroup.Button variant="default" type="submit">
87-
<ArrowRightIcon />
88-
Send Code
89-
</InputGroup.Button>
90-
</InputGroup.Addon>
91-
</InputGroup.Root>
92-
</form>
72+
}}
73+
>
74+
Continue with Hack Club
75+
</Button>
76+
<form class="flex w-full flex-col gap-2">
77+
<Label for="email-{id}">Email</Label>
78+
<InputGroup.Root class="w-full">
79+
<InputGroup.Input
80+
type="email"
81+
name="email"
82+
id="email-{id}"
83+
required
84+
placeholder="iwill@hackthisclub.com"
85+
/>
86+
<InputGroup.Addon align="inline-end">
87+
<InputGroup.Button variant="default" type="submit">
88+
<ArrowRightIcon />
89+
Send Code
90+
</InputGroup.Button>
91+
</InputGroup.Addon>
92+
</InputGroup.Root>
93+
</form>
94+
{/if}
9395
</Card.Content>
9496
{/if}
9597
</Card.Root>

0 commit comments

Comments
 (0)