|
1 | 1 | <script lang="ts"> |
2 | 2 | import LayoutWrapper from '../(layout-partials)/LayoutWrapper.svelte'; |
3 | | -
|
4 | | - import { enhance } from '$app/forms'; |
5 | | - import type { ActionData } from './$types'; |
6 | | -
|
7 | | - import { ccdSignInWithEmailAndPassword } from '$lib/client/firebase'; |
8 | | -
|
9 | | - import { toastStore } from '@codingcatdev/blackcatui'; |
10 | | -
|
11 | 3 | import GoogleAuth from './GoogleAuth.svelte'; |
12 | 4 | import TwitterAuth from './TwitterAuth.svelte'; |
13 | 5 | import GitHubAuth from './GitHubAuth.svelte'; |
|
16 | 8 | // export let form: ActionData; |
17 | 9 |
|
18 | 10 | import type { PageData } from './$types'; |
| 11 | + import EmailAuth from './EmailAuth.svelte'; |
19 | 12 | export let data: PageData; |
20 | 13 | $: action = `?/login&redirectTo=${data.redirectTo ? data.redirectTo : '/dashboard'}`; |
21 | 14 | </script> |
22 | 15 |
|
23 | 16 | <LayoutWrapper> |
24 | 17 | <section class="bcu-card flex flex-col gap-4 p-4"> |
25 | | - <form |
26 | | - class="flex justify-center w-full" |
27 | | - method="POST" |
28 | | - {action} |
29 | | - use:enhance={async ({ action, cancel, controller, data, form }) => { |
30 | | - // `form` is the `<form>` element |
31 | | - // `data` is its `FormData` object |
32 | | - // `action` is the URL to which the form is posted |
33 | | - // `cancel()` will prevent the submission |
34 | | - |
35 | | - const email = `${data.get('email')}`; |
36 | | - const password = `${data.get('password')}`; |
37 | | - |
38 | | - if (!email || !password) { |
39 | | - toastStore.trigger({ |
40 | | - message: 'Please Provide Username and Password.' |
41 | | - }); |
42 | | - cancel(); |
43 | | - } else { |
44 | | - try { |
45 | | - await ccdSignInWithEmailAndPassword({ email, password }); |
46 | | - } catch (err) { |
47 | | - if (err instanceof Error) { |
48 | | - toastStore.trigger({ |
49 | | - message: err.message, |
50 | | - background: 'variant-filled-error' |
51 | | - }); |
52 | | - } |
53 | | - } |
54 | | - } |
55 | | - |
56 | | - return async ({ result, update }) => { |
57 | | - // `result` is an `ActionResult` object |
58 | | - // `update` is a function which triggers the logic that would be triggered if this callback wasn't set |
59 | | - |
60 | | - update(); |
61 | | - }; |
62 | | - }} |
63 | | - > |
64 | | - <div class="flex flex-col gap-4 text-token"> |
65 | | - <label class="label"> |
66 | | - <span>Email</span> |
67 | | - <input class="input" name="email" type="email" placeholder="codercatdev" /> |
68 | | - </label> |
69 | | - <label class="label"> |
70 | | - <span>Password</span> |
71 | | - <input class="input" name="password" type="password" placeholder="****" /> |
72 | | - </label> |
73 | | - <button class="bcu-button variant-filled-primary" type="submit">Login</button> |
74 | | - </div> |
75 | | - </form> |
76 | | - |
| 18 | + <EmailAuth {action} /> |
77 | 19 | <hr /> |
78 | 20 |
|
79 | 21 | <GoogleAuth {action} /> |
80 | | - <TwitterAuth /> |
81 | | - <GitHubAuth /> |
| 22 | + <!-- <TwitterAuth /> --> |
| 23 | + <GitHubAuth {action} /> |
82 | 24 | </section> |
83 | 25 | </LayoutWrapper> |
0 commit comments