@nymphjs/tilmeld-components 1.0.0-beta.15 → 1.0.0-beta.151
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 +572 -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/Account.svelte
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
{#if $clientConfig != null && $user != null}
|
|
2
4
|
<Dialog
|
|
3
|
-
use
|
|
5
|
+
{use}
|
|
4
6
|
bind:open
|
|
5
7
|
aria-labelledby="tilmeld-account-title"
|
|
6
8
|
aria-describedby="tilmeld-account-content"
|
|
7
9
|
surface$class="tilmeld-account-dialog-surface"
|
|
8
|
-
{...exclude(
|
|
10
|
+
{...exclude(restProps, [
|
|
9
11
|
'username$',
|
|
10
12
|
'email$',
|
|
11
13
|
'nameFirst$',
|
|
@@ -13,247 +15,417 @@
|
|
|
13
15
|
'nameLast$',
|
|
14
16
|
'phone$',
|
|
15
17
|
'changePasswordLink$',
|
|
18
|
+
'revokeTokensLink$',
|
|
16
19
|
'closeButton$',
|
|
17
20
|
'saveButton$',
|
|
18
21
|
'changePassword$',
|
|
22
|
+
'revokeTokens$',
|
|
23
|
+
'twoFactor$',
|
|
19
24
|
'progress$',
|
|
20
25
|
])}
|
|
21
26
|
>
|
|
22
27
|
<!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
|
|
23
28
|
<Title id="tilmeld-account-title">{title}</Title>
|
|
24
29
|
<Content id="tilmeld-account-content">
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
<form onsubmit={preventDefault(stopPropagation(save))}>
|
|
31
|
+
{#if !$clientConfig.emailUsernames && $clientConfig.allowUsernameChange}
|
|
32
|
+
<div>
|
|
33
|
+
<Textfield
|
|
34
|
+
bind:value={$user.username}
|
|
35
|
+
label="Username"
|
|
36
|
+
type="text"
|
|
37
|
+
style="width: 100%;"
|
|
38
|
+
helperLine$style="width: 100%;"
|
|
39
|
+
invalid={usernameVerified === false}
|
|
40
|
+
input$autocomplete="username"
|
|
41
|
+
input$autocapitalize="off"
|
|
42
|
+
input$spellcheck="false"
|
|
43
|
+
input$emptyValueUndefined
|
|
44
|
+
{...prefixFilter(restProps, 'username$')}
|
|
45
|
+
>
|
|
46
|
+
{#snippet helper()}
|
|
47
|
+
<HelperText persistent>
|
|
48
|
+
{usernameVerifiedMessage || ''}
|
|
49
|
+
</HelperText>
|
|
50
|
+
{/snippet}
|
|
51
|
+
</Textfield>
|
|
52
|
+
</div>
|
|
53
|
+
{/if}
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
{#if $clientConfig.emailUsernames || $clientConfig.userFields.includes('email')}
|
|
56
|
+
<div>
|
|
57
|
+
<Textfield
|
|
58
|
+
bind:value={$user.email}
|
|
59
|
+
label="Email"
|
|
60
|
+
type="email"
|
|
61
|
+
style="width: 100%;"
|
|
62
|
+
helperLine$style="width: 100%;"
|
|
63
|
+
invalid={emailVerified === false}
|
|
64
|
+
input$autocomplete="email"
|
|
65
|
+
input$autocapitalize="off"
|
|
66
|
+
input$spellcheck="false"
|
|
67
|
+
input$emptyValueUndefined
|
|
68
|
+
{...prefixFilter(restProps, 'email$')}
|
|
69
|
+
>
|
|
70
|
+
{#snippet helper()}
|
|
71
|
+
<HelperText persistent>
|
|
72
|
+
{emailVerifiedMessage || ''}
|
|
73
|
+
</HelperText>
|
|
74
|
+
{/snippet}
|
|
75
|
+
</Textfield>
|
|
76
|
+
</div>
|
|
77
|
+
{/if}
|
|
68
78
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
{#if $clientConfig.userFields.includes('name')}
|
|
80
|
+
<div>
|
|
81
|
+
<Textfield
|
|
82
|
+
bind:value={$user.nameFirst}
|
|
83
|
+
label="First Name"
|
|
84
|
+
type="text"
|
|
85
|
+
style="width: 100%;"
|
|
86
|
+
input$autocomplete="given-name"
|
|
87
|
+
input$emptyValueUndefined
|
|
88
|
+
{...prefixFilter(restProps, 'nameFirst$')}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
81
91
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
<div>
|
|
93
|
+
<Textfield
|
|
94
|
+
bind:value={$user.nameMiddle}
|
|
95
|
+
label="Middle Name"
|
|
96
|
+
type="text"
|
|
97
|
+
style="width: 100%;"
|
|
98
|
+
input$autocomplete="additional-name"
|
|
99
|
+
input$emptyValueUndefined
|
|
100
|
+
{...prefixFilter(restProps, 'nameMiddle$')}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
93
103
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
<div>
|
|
105
|
+
<Textfield
|
|
106
|
+
bind:value={$user.nameLast}
|
|
107
|
+
label="Last Name"
|
|
108
|
+
type="text"
|
|
109
|
+
style="width: 100%;"
|
|
110
|
+
input$autocomplete="family-name"
|
|
111
|
+
input$emptyValueUndefined
|
|
112
|
+
{...prefixFilter(restProps, 'nameLast$')}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
{/if}
|
|
116
|
+
|
|
117
|
+
{#if $clientConfig.userFields.includes('phone')}
|
|
118
|
+
<div>
|
|
119
|
+
<Textfield
|
|
120
|
+
bind:value={$user.phone}
|
|
121
|
+
label="Phone Number"
|
|
122
|
+
type="tel"
|
|
123
|
+
style="width: 100%;"
|
|
124
|
+
input$autocomplete="tel"
|
|
125
|
+
input$name="phone"
|
|
126
|
+
input$emptyValueUndefined
|
|
127
|
+
{...prefixFilter(restProps, 'phone$')}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
{/if}
|
|
106
131
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
{@render additional?.()}
|
|
133
|
+
|
|
134
|
+
<div class="tilmeld-account-action">
|
|
135
|
+
<a
|
|
136
|
+
href={'javascript:void(0);'}
|
|
137
|
+
onclick={() => {
|
|
138
|
+
open = false;
|
|
139
|
+
changePasswordOpen = true;
|
|
140
|
+
}}
|
|
141
|
+
{...prefixFilter(restProps, 'changePasswordLink$')}
|
|
142
|
+
>
|
|
143
|
+
Change your password.
|
|
144
|
+
</a>
|
|
119
145
|
</div>
|
|
120
|
-
{/if}
|
|
121
146
|
|
|
122
|
-
|
|
147
|
+
<div class="tilmeld-account-action">
|
|
148
|
+
<a
|
|
149
|
+
href={'javascript:void(0);'}
|
|
150
|
+
onclick={() => {
|
|
151
|
+
open = false;
|
|
152
|
+
revokeTokensOpen = true;
|
|
153
|
+
}}
|
|
154
|
+
{...prefixFilter(restProps, 'revokeTokensLink$')}
|
|
155
|
+
>
|
|
156
|
+
Log out of other sessions.
|
|
157
|
+
</a>
|
|
123
158
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
159
|
+
<div class="tilmeld-account-action">
|
|
160
|
+
<a
|
|
161
|
+
href={'javascript:void(0);'}
|
|
162
|
+
onclick={() => {
|
|
163
|
+
open = false;
|
|
164
|
+
twoFactorOpen = true;
|
|
165
|
+
}}
|
|
166
|
+
{...prefixFilter(restProps, 'twoFactor$')}
|
|
167
|
+
>
|
|
168
|
+
{#if hasTOTPSecret === false}
|
|
169
|
+
Enable two factor authentication (2FA).
|
|
170
|
+
{:else}
|
|
171
|
+
Manage two factor authentication (2FA).
|
|
172
|
+
{/if}
|
|
173
|
+
</a>
|
|
174
|
+
</div>
|
|
136
175
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
176
|
+
{#if failureMessage}
|
|
177
|
+
<div class="tilmeld-account-failure">
|
|
178
|
+
{failureMessage}
|
|
179
|
+
</div>
|
|
180
|
+
{/if}
|
|
142
181
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
182
|
+
{#if loading}
|
|
183
|
+
<div class="tilmeld-account-loading">
|
|
184
|
+
<CircularProgress
|
|
185
|
+
style="height: 24px; width: 24px;"
|
|
186
|
+
indeterminate
|
|
187
|
+
{...prefixFilter(restProps, 'progress$')}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
{/if}
|
|
150
191
|
</div>
|
|
151
|
-
|
|
192
|
+
</form>
|
|
152
193
|
</Content>
|
|
153
194
|
<Actions>
|
|
154
|
-
<Button disabled={
|
|
195
|
+
<Button disabled={loading} {...prefixFilter(restProps, 'closeButton$')}>
|
|
155
196
|
<Label>Close</Label>
|
|
156
197
|
</Button>
|
|
157
198
|
<Button
|
|
158
|
-
|
|
159
|
-
disabled={
|
|
160
|
-
{...prefixFilter(
|
|
199
|
+
onclick={preventDefault(stopPropagation(save))}
|
|
200
|
+
disabled={loading}
|
|
201
|
+
{...prefixFilter(restProps, 'saveButton$')}
|
|
161
202
|
>
|
|
162
203
|
<Label>Save Changes</Label>
|
|
163
204
|
</Button>
|
|
164
205
|
</Actions>
|
|
165
206
|
</Dialog>
|
|
207
|
+
|
|
166
208
|
<ChangePassword
|
|
167
209
|
{User}
|
|
168
210
|
bind:open={changePasswordOpen}
|
|
169
211
|
bind:user
|
|
170
|
-
{...prefixFilter(
|
|
212
|
+
{...prefixFilter(restProps, 'changePassword$')}
|
|
213
|
+
/>
|
|
214
|
+
|
|
215
|
+
<RevokeTokens
|
|
216
|
+
{User}
|
|
217
|
+
bind:open={revokeTokensOpen}
|
|
218
|
+
bind:user
|
|
219
|
+
{...prefixFilter(restProps, 'revokeTokens$')}
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
<TwoFactor
|
|
223
|
+
{User}
|
|
224
|
+
bind:open={twoFactorOpen}
|
|
225
|
+
bind:user
|
|
226
|
+
bind:hasTOTPSecret
|
|
227
|
+
{...prefixFilter(restProps, 'twoFactor$')}
|
|
171
228
|
/>
|
|
172
229
|
{/if}
|
|
173
230
|
|
|
174
231
|
<script lang="ts">
|
|
232
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
175
233
|
import { onMount, onDestroy } from 'svelte';
|
|
176
|
-
import {
|
|
234
|
+
import type { Writable } from 'svelte/store';
|
|
235
|
+
import { writable } from 'svelte/store';
|
|
177
236
|
import CircularProgress from '@smui/circular-progress';
|
|
178
237
|
import Dialog, { Title, Content, Actions } from '@smui/dialog';
|
|
179
238
|
import Textfield from '@smui/textfield';
|
|
180
239
|
import HelperText from '@smui/textfield/helper-text';
|
|
181
240
|
import Button, { Label } from '@smui/button';
|
|
182
241
|
import type { ActionArray } from '@smui/common/internal';
|
|
183
|
-
import {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
prefixFilter,
|
|
187
|
-
} from '@smui/common/internal';
|
|
242
|
+
import { exclude, prefixFilter } from '@smui/common/internal';
|
|
243
|
+
import { preventDefault, stopPropagation } from '@smui/common/events';
|
|
244
|
+
import type { SmuiElementPropMap } from '@smui/common';
|
|
188
245
|
import type { ClientConfig, CurrentUserData } from '@nymphjs/tilmeld-client';
|
|
189
246
|
import type { User as UserClass } from '@nymphjs/tilmeld-client';
|
|
190
247
|
import ChangePassword from './ChangePassword.svelte';
|
|
248
|
+
import RevokeTokens from './RevokeTokens.svelte';
|
|
249
|
+
import TwoFactor from './TwoFactor.svelte';
|
|
191
250
|
|
|
192
|
-
|
|
251
|
+
type OwnProps = {
|
|
252
|
+
/**
|
|
253
|
+
* An array of Action or [Action, ActionProps] to be applied to the element.
|
|
254
|
+
*/
|
|
255
|
+
use?: ActionArray;
|
|
256
|
+
/**
|
|
257
|
+
* Whether the dialog is open.
|
|
258
|
+
*/
|
|
259
|
+
open?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* The title of the dialog.
|
|
262
|
+
*/
|
|
263
|
+
title?: string;
|
|
264
|
+
/**
|
|
265
|
+
* A writable store of the Nymph client config.
|
|
266
|
+
*
|
|
267
|
+
* It will be retrieved from the server if not provided.
|
|
268
|
+
*/
|
|
269
|
+
clientConfig?: Writable<ClientConfig | undefined>;
|
|
270
|
+
/**
|
|
271
|
+
* The User class from Nymph.
|
|
272
|
+
*/
|
|
273
|
+
User: typeof UserClass;
|
|
274
|
+
/**
|
|
275
|
+
* A writable store of the current user.
|
|
276
|
+
*
|
|
277
|
+
* It will be retrieved from the server if not provided.
|
|
278
|
+
*/
|
|
279
|
+
user?: Writable<(UserClass & CurrentUserData) | null | undefined>;
|
|
193
280
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
281
|
+
/**
|
|
282
|
+
* A spot for additional content.
|
|
283
|
+
*/
|
|
284
|
+
additional?: Snippet;
|
|
285
|
+
};
|
|
286
|
+
let {
|
|
287
|
+
use = [],
|
|
288
|
+
open = $bindable(false),
|
|
289
|
+
title = 'Your Account',
|
|
290
|
+
clientConfig = $bindable(writable(false as unknown as undefined)),
|
|
291
|
+
User,
|
|
292
|
+
user = $bindable(writable(false as unknown as undefined)),
|
|
293
|
+
additional,
|
|
294
|
+
...restProps
|
|
295
|
+
}: OwnProps & {
|
|
296
|
+
[
|
|
297
|
+
k in keyof ComponentProps<typeof Textfield> as `username\$${k}`
|
|
298
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
299
|
+
} & {
|
|
300
|
+
[
|
|
301
|
+
k in keyof ComponentProps<typeof Textfield> as `email\$${k}`
|
|
302
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
303
|
+
} & {
|
|
304
|
+
[
|
|
305
|
+
k in keyof ComponentProps<typeof Textfield> as `nameFirst\$${k}`
|
|
306
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
307
|
+
} & {
|
|
308
|
+
[
|
|
309
|
+
k in keyof ComponentProps<typeof Textfield> as `nameMiddle\$${k}`
|
|
310
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
311
|
+
} & {
|
|
312
|
+
[
|
|
313
|
+
k in keyof ComponentProps<typeof Textfield> as `nameLast\$${k}`
|
|
314
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
315
|
+
} & {
|
|
316
|
+
[
|
|
317
|
+
k in keyof ComponentProps<typeof Textfield> as `phone\$${k}`
|
|
318
|
+
]?: ComponentProps<typeof Textfield>[k];
|
|
319
|
+
} & {
|
|
320
|
+
[
|
|
321
|
+
k in keyof SmuiElementPropMap['a'] as `changePasswordLink\$${k}`
|
|
322
|
+
]?: SmuiElementPropMap['a'][k];
|
|
323
|
+
} & {
|
|
324
|
+
[
|
|
325
|
+
k in keyof SmuiElementPropMap['a'] as `revokeTokensLink\$${k}`
|
|
326
|
+
]?: SmuiElementPropMap['a'][k];
|
|
327
|
+
} & {
|
|
328
|
+
[
|
|
329
|
+
k in keyof ComponentProps<typeof CircularProgress> as `progress\$${k}`
|
|
330
|
+
]?: ComponentProps<typeof CircularProgress>[k];
|
|
331
|
+
} & {
|
|
332
|
+
[
|
|
333
|
+
k in keyof ComponentProps<
|
|
334
|
+
typeof Button<undefined, 'button'>
|
|
335
|
+
> as `closeButton\$${k}`
|
|
336
|
+
]?: ComponentProps<typeof Button<undefined, 'button'>>[k];
|
|
337
|
+
} & {
|
|
338
|
+
[
|
|
339
|
+
k in keyof ComponentProps<
|
|
340
|
+
typeof Button<undefined, 'button'>
|
|
341
|
+
> as `saveButton\$${k}`
|
|
342
|
+
]?: ComponentProps<typeof Button<undefined, 'button'>>[k];
|
|
343
|
+
} & {
|
|
344
|
+
[
|
|
345
|
+
k in keyof ComponentProps<typeof ChangePassword> as `changePassword\$${k}`
|
|
346
|
+
]?: ComponentProps<typeof ChangePassword>[k];
|
|
347
|
+
} & {
|
|
348
|
+
[
|
|
349
|
+
k in keyof ComponentProps<typeof RevokeTokens> as `revokeTokens\$${k}`
|
|
350
|
+
]?: ComponentProps<typeof RevokeTokens>[k];
|
|
351
|
+
} & {
|
|
352
|
+
[
|
|
353
|
+
k in keyof ComponentProps<typeof TwoFactor> as `twoFactor\$${k}`
|
|
354
|
+
]?: ComponentProps<typeof TwoFactor>[k];
|
|
355
|
+
} = $props();
|
|
201
356
|
|
|
202
|
-
let
|
|
203
|
-
let originalUsername: string | undefined =
|
|
204
|
-
let originalEmail: string | undefined =
|
|
205
|
-
let failureMessage: string | undefined =
|
|
206
|
-
let usernameTimer:
|
|
207
|
-
let usernameVerified: boolean | undefined =
|
|
208
|
-
let usernameVerifiedMessage: string | undefined =
|
|
209
|
-
let emailTimer:
|
|
210
|
-
let emailVerified: boolean | undefined =
|
|
211
|
-
let emailVerifiedMessage: string | undefined =
|
|
212
|
-
let
|
|
357
|
+
let loading = $state(false);
|
|
358
|
+
let originalUsername: string | undefined = $user?.username;
|
|
359
|
+
let originalEmail: string | undefined = $user?.email;
|
|
360
|
+
let failureMessage: string | undefined = $state();
|
|
361
|
+
let usernameTimer: number | undefined = undefined;
|
|
362
|
+
let usernameVerified: boolean | undefined = $state();
|
|
363
|
+
let usernameVerifiedMessage: string | undefined = $state();
|
|
364
|
+
let emailTimer: number | undefined = undefined;
|
|
365
|
+
let emailVerified: boolean | undefined = $state();
|
|
366
|
+
let emailVerifiedMessage: string | undefined = $state();
|
|
367
|
+
let hasTOTPSecret: boolean | null = $state(null);
|
|
368
|
+
let changePasswordOpen = $state(false);
|
|
369
|
+
let revokeTokensOpen = $state(false);
|
|
370
|
+
let twoFactorOpen = $state(false);
|
|
213
371
|
|
|
214
372
|
const onLogin = (currentUser: UserClass & CurrentUserData) => {
|
|
215
|
-
user = currentUser;
|
|
216
|
-
originalUsername = user?.username;
|
|
217
|
-
originalEmail = user?.email;
|
|
373
|
+
$user = currentUser;
|
|
374
|
+
originalUsername = $user?.username;
|
|
375
|
+
originalEmail = $user?.email;
|
|
218
376
|
};
|
|
219
377
|
const onLogout = () => {
|
|
220
|
-
user =
|
|
378
|
+
$user = null;
|
|
221
379
|
originalUsername = undefined;
|
|
222
380
|
originalEmail = undefined;
|
|
223
381
|
};
|
|
224
382
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
383
|
+
$effect(() => {
|
|
384
|
+
if ($user && $user.username !== originalUsername) {
|
|
385
|
+
if ($user.$isDirty('username')) {
|
|
386
|
+
checkUsername();
|
|
387
|
+
} else {
|
|
388
|
+
originalUsername = $user.username;
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
if (usernameTimer) {
|
|
392
|
+
clearTimeout(usernameTimer);
|
|
393
|
+
}
|
|
394
|
+
usernameVerified = true;
|
|
395
|
+
usernameVerifiedMessage = undefined;
|
|
230
396
|
}
|
|
231
|
-
|
|
232
|
-
usernameVerifiedMessage = undefined;
|
|
233
|
-
}
|
|
397
|
+
});
|
|
234
398
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
399
|
+
$effect(() => {
|
|
400
|
+
if ($user && $user.email !== originalEmail) {
|
|
401
|
+
if ($user.$isDirty('email')) {
|
|
402
|
+
checkEmail();
|
|
403
|
+
} else {
|
|
404
|
+
originalEmail = $user.email;
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
if (emailTimer) {
|
|
408
|
+
clearTimeout(emailTimer);
|
|
409
|
+
}
|
|
410
|
+
emailVerified = true;
|
|
411
|
+
emailVerifiedMessage = undefined;
|
|
240
412
|
}
|
|
241
|
-
|
|
242
|
-
emailVerifiedMessage = undefined;
|
|
243
|
-
}
|
|
413
|
+
});
|
|
244
414
|
|
|
245
415
|
onMount(async () => {
|
|
246
416
|
User.on('login', onLogin);
|
|
247
417
|
User.on('logout', onLogout);
|
|
248
|
-
if (user === undefined) {
|
|
249
|
-
user =
|
|
418
|
+
if ($user === (false as unknown as undefined)) {
|
|
419
|
+
$user = undefined;
|
|
420
|
+
$user = await User.current();
|
|
250
421
|
}
|
|
251
|
-
originalUsername = user?.username;
|
|
252
|
-
originalEmail = user?.email;
|
|
422
|
+
originalUsername = $user?.username;
|
|
423
|
+
originalEmail = $user?.email;
|
|
253
424
|
});
|
|
254
425
|
onMount(async () => {
|
|
255
|
-
if (clientConfig === undefined) {
|
|
256
|
-
clientConfig =
|
|
426
|
+
if ($clientConfig === (false as unknown as undefined)) {
|
|
427
|
+
$clientConfig = undefined;
|
|
428
|
+
$clientConfig = await User.getClientConfig();
|
|
257
429
|
}
|
|
258
430
|
});
|
|
259
431
|
|
|
@@ -263,30 +435,27 @@
|
|
|
263
435
|
});
|
|
264
436
|
|
|
265
437
|
async function save() {
|
|
266
|
-
if (user == null) {
|
|
438
|
+
if ($user == null) {
|
|
267
439
|
return;
|
|
268
440
|
}
|
|
269
441
|
|
|
270
442
|
failureMessage = undefined;
|
|
271
|
-
|
|
443
|
+
loading = true;
|
|
272
444
|
|
|
273
|
-
if (clientConfig?.emailUsernames) {
|
|
274
|
-
user.username = user.email;
|
|
445
|
+
if ($clientConfig?.emailUsernames) {
|
|
446
|
+
$user.username = $user.email;
|
|
275
447
|
}
|
|
276
448
|
|
|
277
449
|
try {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
} else {
|
|
284
|
-
failureMessage = 'Error saving account changes.';
|
|
285
|
-
}
|
|
450
|
+
await $user.$save();
|
|
451
|
+
originalEmail = $user.email;
|
|
452
|
+
open = false;
|
|
453
|
+
usernameVerifiedMessage = undefined;
|
|
454
|
+
emailVerifiedMessage = undefined;
|
|
286
455
|
} catch (e: any) {
|
|
287
456
|
failureMessage = e?.message;
|
|
288
457
|
}
|
|
289
|
-
|
|
458
|
+
loading = false;
|
|
290
459
|
}
|
|
291
460
|
|
|
292
461
|
function checkUsername() {
|
|
@@ -298,7 +467,7 @@
|
|
|
298
467
|
}
|
|
299
468
|
usernameTimer = setTimeout(async () => {
|
|
300
469
|
try {
|
|
301
|
-
const data = await user?.$checkUsername();
|
|
470
|
+
const data = await $user?.$checkUsername();
|
|
302
471
|
usernameVerified = data?.result ?? false;
|
|
303
472
|
usernameVerifiedMessage =
|
|
304
473
|
data?.message ?? 'Error getting verification.';
|
|
@@ -318,7 +487,7 @@
|
|
|
318
487
|
}
|
|
319
488
|
emailTimer = setTimeout(async () => {
|
|
320
489
|
try {
|
|
321
|
-
const data = await user?.$checkEmail();
|
|
490
|
+
const data = await $user?.$checkEmail();
|
|
322
491
|
emailVerified = data?.result ?? false;
|
|
323
492
|
emailVerifiedMessage = data?.message ?? 'Error getting verification.';
|
|
324
493
|
} catch (e: any) {
|