@nymphjs/tilmeld-components 1.0.0-beta.14 → 1.0.0-beta.141
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/CHANGELOG.md +536 -0
- package/README.md +6 -4
- package/dist/Account.svelte +518 -0
- package/dist/ChangePassword.svelte +311 -0
- package/dist/Login.svelte +614 -0
- package/dist/Recover.svelte +479 -0
- package/dist/RevokeTokens.svelte +238 -0
- package/dist/TwoFactor.svelte +558 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/{lib → dist}/index.js.map +1 -1
- package/jest.config.js +32 -0
- package/package.json +54 -43
- package/src/Account.svelte +359 -190
- package/src/ChangePassword.svelte +190 -92
- package/src/Login.svelte +344 -120
- package/src/Recover.svelte +301 -183
- package/src/RevokeTokens.svelte +238 -0
- package/src/TwoFactor.svelte +558 -0
- package/src/index.d.ts +3 -1
- package/src/index.ts +3 -1
- package/tsconfig.json +8 -4
- package/typedoc.json +4 -0
- package/dist/index.cjs +0 -3
- package/dist/index.cjs.LICENSE.txt +0 -45
- package/dist/index.cjs.map +0 -1
- package/jest.config.cjs +0 -6
- package/lib/Account.svelte +0 -333
- package/lib/Account.svelte.map +0 -1
- package/lib/ChangePassword.svelte +0 -188
- package/lib/ChangePassword.svelte.map +0 -1
- package/lib/Login.svelte +0 -353
- package/lib/Login.svelte.map +0 -1
- package/lib/Recover.svelte +0 -339
- package/lib/Recover.svelte.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -6
- package/webpack.config.cjs +0 -35
package/src/Recover.svelte
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
{#if $clientConfig != null && $clientConfig.pwRecovery}
|
|
2
4
|
<Dialog
|
|
3
|
-
use
|
|
5
|
+
{use}
|
|
4
6
|
bind:open
|
|
5
7
|
aria-labelledby="tilmeld-recovery-title"
|
|
6
8
|
aria-describedby="tilmeld-recovery-content"
|
|
7
9
|
surface$class="tilmeld-recover-dialog-surface"
|
|
8
|
-
{...exclude(
|
|
10
|
+
{...exclude(restProps, [
|
|
9
11
|
'recoveryTypePassword$',
|
|
10
12
|
'recoveryTypeUsername$',
|
|
11
13
|
'account$',
|
|
@@ -26,179 +28,199 @@
|
|
|
26
28
|
{#if successRecoveredMessage}
|
|
27
29
|
{successRecoveredMessage}
|
|
28
30
|
{:else}
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
<form
|
|
32
|
+
onsubmit={preventDefault(
|
|
33
|
+
stopPropagation(() => {
|
|
34
|
+
if (!successRecoveredMessage) {
|
|
35
|
+
if (!hasSentSecret) {
|
|
36
|
+
sendRecovery();
|
|
37
|
+
} else {
|
|
38
|
+
recover();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
{#if !hasSentSecret}
|
|
45
|
+
{#if !$clientConfig.emailUsernames}
|
|
46
|
+
<div>
|
|
47
|
+
<FormField style="margin-right: 1em;">
|
|
48
|
+
<Radio
|
|
49
|
+
bind:group={recoveryType}
|
|
50
|
+
value="password"
|
|
51
|
+
{...prefixFilter(restProps, 'recoveryTypePassword$')}
|
|
52
|
+
/>
|
|
53
|
+
{#snippet label()}
|
|
54
|
+
I don't know my password.
|
|
55
|
+
{/snippet}
|
|
56
|
+
</FormField>
|
|
57
|
+
<FormField style="margin-right: 1em;">
|
|
58
|
+
<Radio
|
|
59
|
+
bind:group={recoveryType}
|
|
60
|
+
value="username"
|
|
61
|
+
{...prefixFilter(restProps, 'recoveryTypeUsername$')}
|
|
62
|
+
/>
|
|
63
|
+
{#snippet label()}
|
|
64
|
+
I don't know my username.
|
|
65
|
+
{/snippet}
|
|
66
|
+
</FormField>
|
|
67
|
+
</div>
|
|
59
68
|
{/if}
|
|
60
|
-
{#if recoveryType === 'username'}
|
|
61
|
-
<p>
|
|
62
|
-
To get your username, type your email as you entered it when
|
|
63
|
-
creating your account.
|
|
64
|
-
</p>
|
|
65
|
-
{/if}
|
|
66
|
-
</div>
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
input$spellcheck="false"
|
|
84
|
-
{...prefixFilter($$restProps, 'account$')}
|
|
85
|
-
/>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
{#if recoveryType === 'password'}
|
|
89
|
-
<div class="tilmeld-recover-action">
|
|
90
|
-
<a
|
|
91
|
-
href="javascript:void(0);"
|
|
92
|
-
on:click={() => (hasSentSecret = 1)}
|
|
93
|
-
{...prefixFilter($$restProps, 'alreadyGotCodeLink$')}
|
|
94
|
-
>
|
|
95
|
-
Already Got a Code?
|
|
96
|
-
</a>
|
|
70
|
+
<div>
|
|
71
|
+
{#if recoveryType === 'password'}
|
|
72
|
+
<p>
|
|
73
|
+
To reset your password, type the {$clientConfig.emailUsernames
|
|
74
|
+
? 'email'
|
|
75
|
+
: 'username'}
|
|
76
|
+
you use to sign in below.
|
|
77
|
+
</p>
|
|
78
|
+
{/if}
|
|
79
|
+
{#if recoveryType === 'username'}
|
|
80
|
+
<p>
|
|
81
|
+
To get your username, type your email as you entered it when
|
|
82
|
+
creating your account.
|
|
83
|
+
</p>
|
|
84
|
+
{/if}
|
|
97
85
|
</div>
|
|
98
|
-
{/if}
|
|
99
|
-
{:else}
|
|
100
|
-
<div>
|
|
101
|
-
<p {...prefixFilter($$restProps, 'codeSentMessage$')}>
|
|
102
|
-
A code has been sent to you by email. Enter that code here, and a
|
|
103
|
-
new password for your account.
|
|
104
|
-
</p>
|
|
105
|
-
</div>
|
|
106
86
|
|
|
107
|
-
{#if hasSentSecret === 1}
|
|
108
87
|
<div>
|
|
109
88
|
<Textfield
|
|
110
89
|
bind:this={accountElem}
|
|
111
90
|
bind:value={account}
|
|
112
|
-
label={clientConfig.emailUsernames
|
|
91
|
+
label={$clientConfig.emailUsernames ||
|
|
92
|
+
recoveryType === 'username'
|
|
113
93
|
? 'Email Address'
|
|
114
94
|
: 'Username'}
|
|
115
|
-
type={clientConfig.emailUsernames
|
|
116
|
-
|
|
95
|
+
type={$clientConfig.emailUsernames ||
|
|
96
|
+
recoveryType === 'username'
|
|
97
|
+
? 'email'
|
|
98
|
+
: 'text'}
|
|
99
|
+
input$autocomplete={$clientConfig.emailUsernames ||
|
|
100
|
+
recoveryType === 'username'
|
|
117
101
|
? 'email'
|
|
118
102
|
: 'username'}
|
|
119
103
|
input$autocapitalize="off"
|
|
120
104
|
input$spellcheck="false"
|
|
121
|
-
{...prefixFilter(
|
|
105
|
+
{...prefixFilter(restProps, 'account$')}
|
|
122
106
|
/>
|
|
123
107
|
</div>
|
|
124
|
-
{/if}
|
|
125
108
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
109
|
+
{#if recoveryType === 'password'}
|
|
110
|
+
<div class="tilmeld-recover-action">
|
|
111
|
+
<a
|
|
112
|
+
href={'javascript:void(0);'}
|
|
113
|
+
onclick={() => (hasSentSecret = 1)}
|
|
114
|
+
{...prefixFilter(restProps, 'alreadyGotCodeLink$')}
|
|
115
|
+
>
|
|
116
|
+
Already Got a Code?
|
|
117
|
+
</a>
|
|
118
|
+
</div>
|
|
119
|
+
{/if}
|
|
120
|
+
{:else}
|
|
121
|
+
<div>
|
|
122
|
+
<p {...prefixFilter(restProps, 'codeSentMessage$')}>
|
|
123
|
+
A code has been sent to you by email. Enter that code here, and
|
|
124
|
+
a new password for your account.
|
|
125
|
+
</p>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
{#if hasSentSecret === 1}
|
|
129
|
+
<div>
|
|
130
|
+
<Textfield
|
|
131
|
+
bind:this={accountElem}
|
|
132
|
+
bind:value={account}
|
|
133
|
+
label={$clientConfig.emailUsernames
|
|
134
|
+
? 'Email Address'
|
|
135
|
+
: 'Username'}
|
|
136
|
+
type={$clientConfig.emailUsernames ? 'email' : 'text'}
|
|
137
|
+
input$autocomplete={$clientConfig.emailUsernames
|
|
138
|
+
? 'email'
|
|
139
|
+
: 'username'}
|
|
140
|
+
input$autocapitalize="off"
|
|
141
|
+
input$spellcheck="false"
|
|
142
|
+
{...prefixFilter(restProps, 'account$')}
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
145
|
+
{/if}
|
|
146
|
+
|
|
147
|
+
<div>
|
|
148
|
+
<Textfield
|
|
149
|
+
bind:value={secret}
|
|
150
|
+
label="Recovery Code"
|
|
151
|
+
type="text"
|
|
152
|
+
input$autocomplete="one-time-code"
|
|
153
|
+
{...prefixFilter(restProps, 'recoveryCode$')}
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
135
156
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
<div>
|
|
158
|
+
<Textfield
|
|
159
|
+
bind:value={password}
|
|
160
|
+
label="Password"
|
|
161
|
+
type="password"
|
|
162
|
+
input$autocomplete="new-password"
|
|
163
|
+
{...prefixFilter(restProps, 'password$')}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
145
166
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
<div>
|
|
168
|
+
<Textfield
|
|
169
|
+
bind:value={password2}
|
|
170
|
+
label="Re-enter Password"
|
|
171
|
+
type="password"
|
|
172
|
+
input$autocomplete="new-password"
|
|
173
|
+
{...prefixFilter(restProps, 'password2$')}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
155
176
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
<div class="tilmeld-recover-action">
|
|
178
|
+
<a
|
|
179
|
+
href={'javascript:void(0);'}
|
|
180
|
+
onclick={() => (hasSentSecret = false)}
|
|
181
|
+
{...prefixFilter(restProps, 'needCodeLink$')}
|
|
182
|
+
>
|
|
183
|
+
Need a New Code?
|
|
184
|
+
</a>
|
|
185
|
+
</div>
|
|
186
|
+
{/if}
|
|
166
187
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
{#if failureMessage}
|
|
189
|
+
<div class="tilmeld-recover-failure">
|
|
190
|
+
{failureMessage}
|
|
191
|
+
</div>
|
|
192
|
+
{/if}
|
|
172
193
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
194
|
+
{#if loading}
|
|
195
|
+
<div class="tilmeld-recover-loading">
|
|
196
|
+
<CircularProgress
|
|
197
|
+
style="height: 24px; width: 24px;"
|
|
198
|
+
indeterminate
|
|
199
|
+
{...prefixFilter(restProps, 'progress$')}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
{/if}
|
|
203
|
+
</form>
|
|
182
204
|
{/if}
|
|
183
205
|
</Content>
|
|
184
206
|
<Actions>
|
|
185
|
-
<Button
|
|
207
|
+
<Button onclick={() => (open = false)} disabled={loading}>
|
|
186
208
|
<Label>{successRecoveredMessage ? 'Close' : 'Cancel'}</Label>
|
|
187
209
|
</Button>
|
|
188
210
|
{#if !successRecoveredMessage}
|
|
189
211
|
{#if !hasSentSecret}
|
|
190
212
|
<Button
|
|
191
|
-
|
|
192
|
-
disabled={
|
|
193
|
-
{...prefixFilter(
|
|
213
|
+
onclick={preventDefault(stopPropagation(sendRecovery))}
|
|
214
|
+
disabled={loading}
|
|
215
|
+
{...prefixFilter(restProps, 'sendCodeButton$')}
|
|
194
216
|
>
|
|
195
217
|
<Label>Send Recovery</Label>
|
|
196
218
|
</Button>
|
|
197
219
|
{:else}
|
|
198
220
|
<Button
|
|
199
|
-
|
|
200
|
-
disabled={
|
|
201
|
-
{...prefixFilter(
|
|
221
|
+
onclick={preventDefault(stopPropagation(recover))}
|
|
222
|
+
disabled={loading}
|
|
223
|
+
{...prefixFilter(restProps, 'resetPasswordButton$')}
|
|
202
224
|
>
|
|
203
225
|
<Label>Reset Password</Label>
|
|
204
226
|
</Button>
|
|
@@ -209,8 +231,10 @@
|
|
|
209
231
|
{/if}
|
|
210
232
|
|
|
211
233
|
<script lang="ts">
|
|
234
|
+
import type { ComponentProps } from 'svelte';
|
|
212
235
|
import { onMount } from 'svelte';
|
|
213
|
-
import {
|
|
236
|
+
import type { Writable } from 'svelte/store';
|
|
237
|
+
import { writable } from 'svelte/store';
|
|
214
238
|
import CircularProgress from '@smui/circular-progress';
|
|
215
239
|
import Dialog, { Title, Content, Actions } from '@smui/dialog';
|
|
216
240
|
import Textfield from '@smui/textfield';
|
|
@@ -218,53 +242,147 @@
|
|
|
218
242
|
import FormField from '@smui/form-field';
|
|
219
243
|
import Radio from '@smui/radio';
|
|
220
244
|
import type { ActionArray } from '@smui/common/internal';
|
|
221
|
-
import {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
prefixFilter,
|
|
225
|
-
} from '@smui/common/internal';
|
|
245
|
+
import { exclude, prefixFilter } from '@smui/common/internal';
|
|
246
|
+
import { preventDefault, stopPropagation } from '@smui/common/events';
|
|
247
|
+
import type { SmuiElementPropMap } from '@smui/common';
|
|
226
248
|
import type {
|
|
227
249
|
User as UserClass,
|
|
228
250
|
ClientConfig,
|
|
229
251
|
} from '@nymphjs/tilmeld-client';
|
|
230
252
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
253
|
+
type OwnProps = {
|
|
254
|
+
/**
|
|
255
|
+
* An array of Action or [Action, ActionProps] to be applied to the element.
|
|
256
|
+
*/
|
|
257
|
+
use?: ActionArray;
|
|
258
|
+
/**
|
|
259
|
+
* Whether the dialog is open.
|
|
260
|
+
*/
|
|
261
|
+
open?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* The title of the dialog.
|
|
264
|
+
*/
|
|
265
|
+
title?: string;
|
|
266
|
+
/**
|
|
267
|
+
* A writable store of the Nymph client config.
|
|
268
|
+
*
|
|
269
|
+
* It will be retrieved from the server if not provided.
|
|
270
|
+
*/
|
|
271
|
+
clientConfig?: Writable<ClientConfig | undefined>;
|
|
272
|
+
/**
|
|
273
|
+
* The User class from Nymph.
|
|
274
|
+
*/
|
|
275
|
+
User: typeof UserClass;
|
|
276
|
+
/**
|
|
277
|
+
* Give focus to the account box when the form is ready.
|
|
278
|
+
*/
|
|
279
|
+
autofocus?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* The type of recovery being requested.
|
|
282
|
+
*
|
|
283
|
+
* User provided. You can bind to it if you need to.
|
|
284
|
+
*/
|
|
285
|
+
recoveryType?: 'username' | 'password';
|
|
286
|
+
/**
|
|
287
|
+
* User provided. You can bind to it if you need to.
|
|
288
|
+
*/
|
|
289
|
+
account?: string;
|
|
290
|
+
/**
|
|
291
|
+
* User provided. You can bind to it if you need to.
|
|
292
|
+
*/
|
|
293
|
+
secret?: string;
|
|
294
|
+
/**
|
|
295
|
+
* User provided. You can bind to it if you need to.
|
|
296
|
+
*/
|
|
297
|
+
password?: string;
|
|
298
|
+
/**
|
|
299
|
+
* User provided. You can bind to it if you need to.
|
|
300
|
+
*/
|
|
301
|
+
password2?: string;
|
|
302
|
+
};
|
|
303
|
+
let {
|
|
304
|
+
use = [],
|
|
305
|
+
open = $bindable(false),
|
|
306
|
+
title = 'Recover Your Account',
|
|
307
|
+
clientConfig = $bindable(writable(false as unknown as undefined)),
|
|
308
|
+
User,
|
|
309
|
+
autofocus = true,
|
|
310
|
+
recoveryType = $bindable('password'),
|
|
311
|
+
account = $bindable(''),
|
|
312
|
+
secret = $bindable(''),
|
|
313
|
+
password = $bindable(''),
|
|
314
|
+
password2 = $bindable(''),
|
|
315
|
+
...restProps
|
|
316
|
+
}: OwnProps & {
|
|
317
|
+
[
|
|
318
|
+
k in keyof ComponentProps<typeof Radio> as `recoveryTypePassword\$${k}`
|
|
319
|
+
]?: ComponentProps<typeof Radio>[k];
|
|
320
|
+
} & {
|
|
321
|
+
[
|
|
322
|
+
k in keyof ComponentProps<typeof Radio> as `recoveryTypeUsername\$${k}`
|
|
323
|
+
]?: ComponentProps<typeof Radio>[k];
|
|
324
|
+
} & {
|
|
325
|
+
[
|
|
326
|
+
k in keyof ComponentProps<typeof Textfield> as `account\$${k}`
|
|
327
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
328
|
+
} & {
|
|
329
|
+
[
|
|
330
|
+
k in keyof SmuiElementPropMap['a'] as `alreadyGotCodeLink\$${k}`
|
|
331
|
+
]?: SmuiElementPropMap['a'][k];
|
|
332
|
+
} & {
|
|
333
|
+
[
|
|
334
|
+
k in keyof SmuiElementPropMap['p'] as `codeSentMessage\$${k}`
|
|
335
|
+
]?: SmuiElementPropMap['p'][k];
|
|
336
|
+
} & {
|
|
337
|
+
[
|
|
338
|
+
k in keyof ComponentProps<typeof Textfield> as `recoveryCode\$${k}`
|
|
339
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
340
|
+
} & {
|
|
341
|
+
[
|
|
342
|
+
k in keyof ComponentProps<typeof Textfield> as `password\$${k}`
|
|
343
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
344
|
+
} & {
|
|
345
|
+
[
|
|
346
|
+
k in keyof ComponentProps<typeof Textfield> as `password2\$${k}`
|
|
347
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
348
|
+
} & {
|
|
349
|
+
[
|
|
350
|
+
k in keyof SmuiElementPropMap['a'] as `needCodeLink\$${k}`
|
|
351
|
+
]?: SmuiElementPropMap['a'][k];
|
|
352
|
+
} & {
|
|
353
|
+
[
|
|
354
|
+
k in keyof ComponentProps<typeof CircularProgress> as `progress\$${k}`
|
|
355
|
+
]?: ComponentProps<typeof CircularProgress>[k];
|
|
356
|
+
} & {
|
|
357
|
+
[
|
|
358
|
+
k in keyof ComponentProps<
|
|
359
|
+
typeof Button<undefined, 'button'>
|
|
360
|
+
> as `sendCodeButton\$${k}`
|
|
361
|
+
]?: ComponentProps<typeof Button<undefined, 'button'>>[k];
|
|
362
|
+
} & {
|
|
363
|
+
[
|
|
364
|
+
k in keyof ComponentProps<
|
|
365
|
+
typeof Button<undefined, 'button'>
|
|
366
|
+
> as `resetPasswordButton\$${k}`
|
|
367
|
+
]?: ComponentProps<typeof Button<undefined, 'button'>>[k];
|
|
368
|
+
} = $props();
|
|
239
369
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
370
|
+
let loading = $state(false);
|
|
371
|
+
let hasSentSecret: number | boolean = $state(false);
|
|
372
|
+
let accountElem: Textfield | undefined = $state();
|
|
373
|
+
let failureMessage: string | undefined = $state();
|
|
374
|
+
let successRecoveredMessage: string | undefined = $state();
|
|
243
375
|
|
|
244
|
-
|
|
245
|
-
export let account = '';
|
|
246
|
-
/** User provided. You can bind to it if you need to. */
|
|
247
|
-
export let secret = '';
|
|
248
|
-
/** User provided. You can bind to it if you need to. */
|
|
249
|
-
export let password = '';
|
|
250
|
-
/** User provided. You can bind to it if you need to. */
|
|
251
|
-
export let password2 = '';
|
|
252
|
-
|
|
253
|
-
let recovering = false;
|
|
254
|
-
let hasSentSecret: number | boolean = false;
|
|
255
|
-
let accountElem: Textfield;
|
|
256
|
-
let failureMessage: string | undefined = undefined;
|
|
257
|
-
let successRecoveredMessage: string | undefined = undefined;
|
|
258
|
-
|
|
259
|
-
$: {
|
|
376
|
+
$effect(() => {
|
|
260
377
|
if (open && autofocus && accountElem) {
|
|
261
378
|
accountElem.focus();
|
|
262
379
|
}
|
|
263
|
-
}
|
|
380
|
+
});
|
|
264
381
|
|
|
265
382
|
onMount(async () => {
|
|
266
|
-
if (clientConfig === undefined) {
|
|
267
|
-
clientConfig =
|
|
383
|
+
if ($clientConfig === (false as unknown as undefined)) {
|
|
384
|
+
$clientConfig = undefined;
|
|
385
|
+
$clientConfig = await User.getClientConfig();
|
|
268
386
|
}
|
|
269
387
|
});
|
|
270
388
|
|
|
@@ -272,7 +390,7 @@
|
|
|
272
390
|
if (account === '') {
|
|
273
391
|
failureMessage =
|
|
274
392
|
'You need to enter ' +
|
|
275
|
-
(clientConfig?.emailUsernames || recoveryType === 'username'
|
|
393
|
+
($clientConfig?.emailUsernames || recoveryType === 'username'
|
|
276
394
|
? 'an email address'
|
|
277
395
|
: 'a username') +
|
|
278
396
|
'.';
|
|
@@ -280,7 +398,7 @@
|
|
|
280
398
|
}
|
|
281
399
|
|
|
282
400
|
failureMessage = undefined;
|
|
283
|
-
|
|
401
|
+
loading = true;
|
|
284
402
|
|
|
285
403
|
try {
|
|
286
404
|
const data = await User.sendRecovery({
|
|
@@ -299,14 +417,14 @@
|
|
|
299
417
|
} catch (e: any) {
|
|
300
418
|
failureMessage = e?.message;
|
|
301
419
|
}
|
|
302
|
-
|
|
420
|
+
loading = false;
|
|
303
421
|
}
|
|
304
422
|
|
|
305
423
|
async function recover() {
|
|
306
424
|
if (account === '') {
|
|
307
425
|
failureMessage =
|
|
308
426
|
'You need to enter ' +
|
|
309
|
-
(clientConfig?.emailUsernames || recoveryType === 'username'
|
|
427
|
+
($clientConfig?.emailUsernames || recoveryType === 'username'
|
|
310
428
|
? 'an email address'
|
|
311
429
|
: 'a username') +
|
|
312
430
|
'.';
|
|
@@ -322,7 +440,7 @@
|
|
|
322
440
|
}
|
|
323
441
|
|
|
324
442
|
failureMessage = undefined;
|
|
325
|
-
|
|
443
|
+
loading = true;
|
|
326
444
|
try {
|
|
327
445
|
const data = await User.recover({
|
|
328
446
|
username: account,
|
|
@@ -337,7 +455,7 @@
|
|
|
337
455
|
} catch (e: any) {
|
|
338
456
|
failureMessage = e?.message;
|
|
339
457
|
}
|
|
340
|
-
|
|
458
|
+
loading = false;
|
|
341
459
|
}
|
|
342
460
|
</script>
|
|
343
461
|
|