@functionalcms/svelte-components 5.24.4 → 5.24.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,23 +7,24 @@ import * as m from "$lib/paraglide/messages.js";
|
|
|
7
7
|
/** @type {import('./$types').PageServerLoad} */
|
|
8
8
|
export async function load({ params, locals, url }) {
|
|
9
9
|
const username = params.email;
|
|
10
|
-
|
|
10
|
+
const code = url.searchParams.get("code");
|
|
11
|
+
return { username, code: code, success: false };
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const actions = {
|
|
14
15
|
setup: async ({ request, locals, params, url }) => {
|
|
15
16
|
const userService = getUsersService(locals);
|
|
16
|
-
const code = url.searchParams.get("code");
|
|
17
17
|
|
|
18
|
-
const data = await convertResponseToFields(fields, request);
|
|
18
|
+
const data = await convertResponseToFields(fields(""), request);
|
|
19
19
|
|
|
20
20
|
if (data.password != data.confirm) {
|
|
21
21
|
return {
|
|
22
|
+
code: data.code,
|
|
22
23
|
errors: new Map<string, string>([["confirm", m.auth_password_do_not_match()]])
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const result = await userService.setup(DOMAIN, params.email);
|
|
27
|
+
const result = await userService.setup(DOMAIN, params.email, data.code, data.password);
|
|
27
28
|
|
|
28
29
|
return { success: true };
|
|
29
30
|
},
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SmartForm } from '@functionalcms/svelte-components';
|
|
3
|
+
import * as m from '$lib/paraglide/messages.js';
|
|
4
|
+
import { deserialize } from '$app/forms';
|
|
5
|
+
import { fields } from './fields.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
interface Props {
|
|
8
|
+
data: {
|
|
9
|
+
username: string | null;
|
|
10
|
+
errors: string;
|
|
11
|
+
};
|
|
12
|
+
form: any;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
let { data, form = {} } = $props();
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
let submitError = $state(false);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let isProcesing = $state(false);
|
|
20
|
+
let resultMessage = $state('');
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
async function resetPassword() {
|
|
23
|
+
isProcesing = true;
|
|
24
|
+
submitError = false;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const response = await fetch('?/setup', {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: ''
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
const result = deserialize(await response.text());
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
resultMessage = result.type === 'success' ? m.auth_setup_success() : m.auth_setup_failure();
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</script>
|
|
35
|
+
isProcesing = false;
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
38
|
|
|
39
|
-
<article class="w-full">
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
<article class="w-full">
|
|
40
|
+
<main class="flex flex-col justify-around items-center gap-4 w-full m-auto p-4">
|
|
41
|
+
<h1>{m.auth_setup_title()}</h1>
|
|
42
|
+
{#if !data.username}
|
|
43
|
+
<p>{m.auth_setup_missing_code()}</p>
|
|
44
|
+
{:else}
|
|
45
|
+
<div>
|
|
46
|
+
{@html m.auth_setup_into()}
|
|
47
|
+
</div>
|
|
48
|
+
<SmartForm
|
|
49
|
+
fields={fields(data.code ?? form.code)}
|
|
50
|
+
errors={form?.errors}
|
|
51
|
+
action="?/setup"
|
|
52
|
+
buttons={[
|
|
53
|
+
{
|
|
54
|
+
type: 'submit',
|
|
55
|
+
label: m.auth_submit(),
|
|
56
|
+
color: 'primary'
|
|
57
|
+
}
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
{#if resultMessage != ''}
|
|
61
|
+
<p>{resultMessage}</p>
|
|
62
|
+
{/if}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</article>
|
|
64
|
+
{#if submitError}
|
|
65
|
+
<p class="text-red-600">{m.auth_setup_error()}</p>
|
|
66
|
+
{/if}
|
|
67
|
+
{/if}
|
|
68
|
+
</main>
|
|
69
|
+
</article>
|
|
70
70
|
|
|
71
|
-
<style>
|
|
72
|
-
</style>
|
|
71
|
+
<style>
|
|
72
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m } from "$lib/paraglide/messages";
|
|
2
|
-
import { createInputField, InputType } from "@functionalcms/svelte-components";
|
|
2
|
+
import { createHiddenField, createInputField, InputType } from "@functionalcms/svelte-components";
|
|
3
3
|
|
|
4
|
-
export const fields = [
|
|
4
|
+
export const fields = (code: string) => [
|
|
5
5
|
createInputField(
|
|
6
6
|
"password",
|
|
7
7
|
m.auth_password(),
|
|
@@ -20,4 +20,8 @@ export const fields = [
|
|
|
20
20
|
required: true,
|
|
21
21
|
},
|
|
22
22
|
),
|
|
23
|
+
createHiddenField(
|
|
24
|
+
"code",
|
|
25
|
+
code
|
|
26
|
+
)
|
|
23
27
|
];
|