@fiduswriter/frontend 0.1.28 → 0.1.29
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/dist/admin_console/index.d.ts +9 -2
- package/dist/admin_console/index.d.ts.map +1 -1
- package/dist/admin_console/index.js.map +1 -1
- package/dist/api/index.d.ts +62 -75
- package/dist/api/index.d.ts.map +1 -1
- package/dist/app/index.d.ts +11 -6
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +66 -23
- package/dist/app/index.js.map +1 -1
- package/dist/document_templates/actions.js +2 -4
- package/dist/document_templates/actions.js.map +1 -1
- package/dist/document_templates/editor.d.ts +2 -2
- package/dist/document_templates/editor.d.ts.map +1 -1
- package/dist/document_templates/editor.js +2 -2
- package/dist/document_templates/editor.js.map +1 -1
- package/dist/document_templates/overview.d.ts +7 -7
- package/dist/document_templates/overview.d.ts.map +1 -1
- package/dist/document_templates/overview.js.map +1 -1
- package/dist/documents/overview/actions.d.ts +3 -2
- package/dist/documents/overview/actions.d.ts.map +1 -1
- package/dist/documents/overview/actions.js +20 -17
- package/dist/documents/overview/actions.js.map +1 -1
- package/dist/documents/overview/index.d.ts +8 -17
- package/dist/documents/overview/index.d.ts.map +1 -1
- package/dist/documents/overview/index.js +2 -2
- package/dist/documents/overview/index.js.map +1 -1
- package/dist/documents/overview/menu.d.ts.map +1 -1
- package/dist/documents/overview/menu.js +2 -2
- package/dist/documents/overview/menu.js.map +1 -1
- package/dist/documents/tools.d.ts +2 -2
- package/dist/documents/tools.d.ts.map +1 -1
- package/dist/documents/tools.js.map +1 -1
- package/dist/e2ee/passphrase_urls.d.ts +10 -0
- package/dist/e2ee/passphrase_urls.d.ts.map +1 -0
- package/dist/e2ee/passphrase_urls.js +23 -0
- package/dist/e2ee/passphrase_urls.js.map +1 -0
- package/dist/error_hook/index.d.ts +8 -1
- package/dist/error_hook/index.d.ts.map +1 -1
- package/dist/error_hook/index.js +10 -12
- package/dist/error_hook/index.js.map +1 -1
- package/dist/feedback/index.d.ts +3 -2
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/maintenance/index.d.ts +3 -2
- package/dist/maintenance/index.d.ts.map +1 -1
- package/dist/maintenance/index.js.map +1 -1
- package/dist/menu/index.d.ts +3 -3
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +0 -1
- package/dist/menu/index.js.map +1 -1
- package/dist/pages/flatpage.js.map +1 -1
- package/dist/prelogin/index.d.ts +3 -7
- package/dist/prelogin/index.d.ts.map +1 -1
- package/dist/prelogin/index.js.map +1 -1
- package/dist/types.d.ts +63 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/user/auth/email_confirm.d.ts +2 -2
- package/dist/user/auth/email_confirm.d.ts.map +1 -1
- package/dist/user/auth/email_confirm.js +5 -6
- package/dist/user/auth/email_confirm.js.map +1 -1
- package/dist/user/auth/login.d.ts +3 -3
- package/dist/user/auth/login.d.ts.map +1 -1
- package/dist/user/auth/login.js +18 -19
- package/dist/user/auth/login.js.map +1 -1
- package/dist/user/auth/password_reset_change.d.ts +2 -2
- package/dist/user/auth/password_reset_change.d.ts.map +1 -1
- package/dist/user/auth/password_reset_change.js +0 -1
- package/dist/user/auth/password_reset_change.js.map +1 -1
- package/dist/user/auth/password_reset_request.d.ts +2 -2
- package/dist/user/auth/password_reset_request.d.ts.map +1 -1
- package/dist/user/auth/password_reset_request.js +0 -1
- package/dist/user/auth/password_reset_request.js.map +1 -1
- package/dist/user/auth/signup.d.ts +2 -2
- package/dist/user/auth/signup.d.ts.map +1 -1
- package/dist/user/auth/signup.js +2 -2
- package/dist/user/auth/signup.js.map +1 -1
- package/dist/user/auth/two_factor.d.ts +7 -5
- package/dist/user/auth/two_factor.d.ts.map +1 -1
- package/dist/user/auth/two_factor.js +3 -2
- package/dist/user/auth/two_factor.js.map +1 -1
- package/dist/user/contacts/add_dialog.d.ts +16 -2
- package/dist/user/contacts/add_dialog.d.ts.map +1 -1
- package/dist/user/contacts/add_dialog.js +4 -4
- package/dist/user/contacts/add_dialog.js.map +1 -1
- package/dist/user/contacts/delete_dialog.d.ts +3 -2
- package/dist/user/contacts/delete_dialog.d.ts.map +1 -1
- package/dist/user/contacts/delete_dialog.js.map +1 -1
- package/dist/user/contacts/index.d.ts +10 -2
- package/dist/user/contacts/index.d.ts.map +1 -1
- package/dist/user/contacts/index.js.map +1 -1
- package/dist/user/contacts/invite.d.ts +3 -2
- package/dist/user/contacts/invite.d.ts.map +1 -1
- package/dist/user/contacts/invite.js +3 -2
- package/dist/user/contacts/invite.js.map +1 -1
- package/dist/user/contacts/menu.d.ts.map +1 -1
- package/dist/user/contacts/menu.js +1 -1
- package/dist/user/contacts/menu.js.map +1 -1
- package/dist/user/contacts/respond_invite.d.ts +3 -2
- package/dist/user/contacts/respond_invite.d.ts.map +1 -1
- package/dist/user/contacts/respond_invite.js.map +1 -1
- package/dist/user/profile/delete_user.d.ts +3 -2
- package/dist/user/profile/delete_user.d.ts.map +1 -1
- package/dist/user/profile/delete_user.js.map +1 -1
- package/dist/user/profile/dialogs.d.ts +8 -7
- package/dist/user/profile/dialogs.d.ts.map +1 -1
- package/dist/user/profile/dialogs.js +3 -4
- package/dist/user/profile/dialogs.js.map +1 -1
- package/dist/user/profile/index.d.ts +9 -4
- package/dist/user/profile/index.d.ts.map +1 -1
- package/dist/user/profile/index.js.map +1 -1
- package/package.json +12 -9
- package/src/admin_console/index.ts +9 -2
- package/src/api/index.ts +78 -39
- package/src/app/index.ts +114 -50
- package/src/document_templates/actions.ts +6 -6
- package/src/document_templates/editor.ts +10 -8
- package/src/document_templates/overview.ts +10 -12
- package/src/documents/overview/actions.ts +52 -25
- package/src/documents/overview/index.ts +16 -27
- package/src/documents/overview/menu.ts +4 -2
- package/src/documents/tools.ts +2 -2
- package/src/error_hook/index.ts +20 -15
- package/src/feedback/index.ts +5 -3
- package/src/index.ts +3 -1
- package/src/maintenance/index.ts +16 -7
- package/src/menu/index.ts +4 -4
- package/src/pages/flatpage.ts +4 -4
- package/src/prelogin/index.ts +4 -8
- package/src/types.ts +53 -9
- package/src/user/auth/email_confirm.ts +19 -19
- package/src/user/auth/login.ts +23 -22
- package/src/user/auth/password_reset_change.ts +4 -4
- package/src/user/auth/password_reset_request.ts +3 -3
- package/src/user/auth/signup.ts +8 -8
- package/src/user/auth/two_factor.ts +31 -22
- package/src/user/contacts/add_dialog.ts +7 -4
- package/src/user/contacts/delete_dialog.ts +3 -2
- package/src/user/contacts/index.ts +14 -4
- package/src/user/contacts/invite.ts +9 -5
- package/src/user/contacts/menu.ts +4 -1
- package/src/user/contacts/respond_invite.ts +3 -2
- package/src/user/profile/delete_user.ts +3 -2
- package/src/user/profile/dialogs.ts +19 -18
- package/src/user/profile/index.ts +13 -10
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface Email {
|
|
2
2
|
address: string
|
|
3
3
|
primary?: boolean
|
|
4
|
+
verified?: boolean
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
export interface User {
|
|
@@ -17,13 +18,8 @@ export interface Route {
|
|
|
17
18
|
|
|
18
19
|
export type RouteMap = Record<string, Route>
|
|
19
20
|
|
|
20
|
-
export interface Settings {
|
|
21
|
-
APPS: string[]
|
|
22
|
-
[key: string]: unknown
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
export interface SiteMenuLike {
|
|
26
|
-
app:
|
|
22
|
+
app: FrontendApp
|
|
27
23
|
navItems: NavItem[]
|
|
28
24
|
}
|
|
29
25
|
|
|
@@ -45,20 +41,68 @@ export type MenuPlugin = Record<string, MenuPluginExport>
|
|
|
45
41
|
|
|
46
42
|
export type MenuPlugins = Array<[string, MenuPlugin]>
|
|
47
43
|
|
|
44
|
+
import type {Settings as FwSettings} from "fwtoolkit/settings"
|
|
45
|
+
import type {ApiConnectors} from "./api/index.js"
|
|
46
|
+
|
|
48
47
|
export interface App {
|
|
49
48
|
routes: RouteMap
|
|
50
49
|
goTo: (url: string) => void
|
|
51
50
|
settings: Settings
|
|
52
51
|
menuPlugins?: MenuPlugins
|
|
53
|
-
apiConnectors
|
|
54
|
-
name
|
|
52
|
+
apiConnectors: ApiConnectors
|
|
53
|
+
name: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface Settings extends FwSettings {
|
|
57
|
+
APPS: string[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface FrontendApp extends App {
|
|
61
|
+
app: FrontendApp
|
|
62
|
+
user: User & {
|
|
63
|
+
is_authenticated?: boolean
|
|
64
|
+
id?: number
|
|
65
|
+
waiting_invites?: boolean
|
|
66
|
+
[key: string]: unknown
|
|
67
|
+
}
|
|
68
|
+
isOffline: () => boolean
|
|
69
|
+
bibDB?: unknown
|
|
70
|
+
csl?: {getStyles(): Promise<unknown>}
|
|
71
|
+
imageDB?: unknown
|
|
72
|
+
indexedDB?: {
|
|
73
|
+
readAllData(store: string): Promise<unknown[]>
|
|
74
|
+
clearData(store: string): Promise<void>
|
|
75
|
+
insertData(store: string, data: Record<string, unknown>[] | undefined): void
|
|
76
|
+
}
|
|
77
|
+
page?: unknown
|
|
78
|
+
plugins?: Record<string, unknown>
|
|
79
|
+
ws?: {
|
|
80
|
+
connectionCount?: number
|
|
81
|
+
connected?: boolean
|
|
82
|
+
init(): void
|
|
83
|
+
close(): void
|
|
84
|
+
}
|
|
85
|
+
ws_url_base?: string
|
|
86
|
+
socialaccount_providers?: Array<Record<string, unknown>>
|
|
87
|
+
inviteKey?: string
|
|
88
|
+
getConfiguration(): Promise<void>
|
|
89
|
+
selectPage(): Promise<void>
|
|
90
|
+
goTo(url: string): Promise<void>
|
|
91
|
+
init(): Promise<any>
|
|
92
|
+
openLoginPage(): {init(): Promise<any>; [key: string]: unknown}
|
|
93
|
+
openOfflinePage(): {init(): Promise<any>; [key: string]: unknown}
|
|
94
|
+
openSetupPage(): {init(): Promise<any>; [key: string]: unknown}
|
|
95
|
+
open404Page(): {init(): Promise<any>; [key: string]: unknown}
|
|
96
|
+
handleSWUpdate(): void
|
|
97
|
+
[key: string]: unknown
|
|
55
98
|
}
|
|
56
99
|
|
|
57
100
|
export interface BaseBodyTemplateOptions {
|
|
58
101
|
user: User
|
|
59
102
|
contents: string
|
|
60
103
|
hasOverview?: boolean
|
|
61
|
-
app:
|
|
104
|
+
app: FrontendApp
|
|
62
105
|
}
|
|
63
106
|
|
|
64
107
|
|
|
108
|
+
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
deactivateWait,
|
|
5
5
|
whenReady
|
|
6
6
|
} from "fwtoolkit"
|
|
7
|
-
import {PreloginPage} from "../../prelogin/index.js"
|
|
7
|
+
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
8
8
|
import {
|
|
9
9
|
checkTermsTemplate,
|
|
10
10
|
confirmAccountTemplate,
|
|
@@ -25,7 +25,7 @@ export class EmailConfirm extends PreloginPage {
|
|
|
25
25
|
confirmMethods: Array<() => Promise<unknown>>
|
|
26
26
|
firstVerification: boolean
|
|
27
27
|
|
|
28
|
-
constructor({app, language}: {app:
|
|
28
|
+
constructor({app, language}: {app: PreloginApp; language: string}, key: string) {
|
|
29
29
|
super({app, language})
|
|
30
30
|
|
|
31
31
|
this.title = gettext("Confirm Email")
|
|
@@ -43,7 +43,7 @@ export class EmailConfirm extends PreloginPage {
|
|
|
43
43
|
this.formChecks = []
|
|
44
44
|
this.confirmQuestionsTemplates = []
|
|
45
45
|
this.confirmMethods = [
|
|
46
|
-
() =>
|
|
46
|
+
() => this.app.apiConnectors.userProfile.confirmEmail(this.key)
|
|
47
47
|
]
|
|
48
48
|
this.firstVerification = false
|
|
49
49
|
}
|
|
@@ -57,7 +57,7 @@ export class EmailConfirm extends PreloginPage {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
getConfirmData(): Promise<void> {
|
|
60
|
-
return
|
|
60
|
+
return this.app.apiConnectors.userProfile.getConfirmKeyData({key: this.key})
|
|
61
61
|
.then((json: any) => {
|
|
62
62
|
this.username = json.username
|
|
63
63
|
this.email = json.email
|
|
@@ -65,7 +65,7 @@ export class EmailConfirm extends PreloginPage {
|
|
|
65
65
|
this.verified = json.verified
|
|
66
66
|
this.firstVerification = !json.verified
|
|
67
67
|
if (json.logout) {
|
|
68
|
-
this.app.config.user = {is_authenticated: false}
|
|
68
|
+
this.app.config.user = {is_authenticated: false} as PreloginApp["user"]
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
71
|
.catch(() => {})
|
|
@@ -127,23 +127,23 @@ export class EmailConfirm extends PreloginPage {
|
|
|
127
127
|
activateWait()
|
|
128
128
|
Promise.all(this.confirmMethods.map(method => method())).then(() => {
|
|
129
129
|
deactivateWait()
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
)
|
|
134
|
-
if (emailObject) {
|
|
135
|
-
emailObject.verified = true
|
|
136
|
-
}
|
|
137
|
-
return (this.app.goTo("/user/profile/") as any)
|
|
138
|
-
.then(() =>
|
|
139
|
-
addAlert("info", gettext("Email verified!"))
|
|
130
|
+
if (this.app.config.user.is_authenticated) {
|
|
131
|
+
const emailObject = this.app.config.user.emails.find(
|
|
132
|
+
email => email.address === this.email
|
|
140
133
|
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (contentsDOM) {
|
|
144
|
-
contentsDOM.innerHTML = verifiedAccountTemplate()
|
|
134
|
+
if (emailObject) {
|
|
135
|
+
emailObject.verified = true
|
|
145
136
|
}
|
|
137
|
+
return this.app.goTo("/user/profile/")
|
|
138
|
+
.then(() =>
|
|
139
|
+
addAlert("info", gettext("Email verified!"))
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
const contentsDOM = document.querySelector(".fw-contents")
|
|
143
|
+
if (contentsDOM) {
|
|
144
|
+
contentsDOM.innerHTML = verifiedAccountTemplate()
|
|
146
145
|
}
|
|
146
|
+
return undefined
|
|
147
147
|
})
|
|
148
148
|
})
|
|
149
149
|
}
|
package/src/user/auth/login.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {escapeText} from "fwtoolkit"
|
|
2
|
-
import {PreloginPage} from "../../prelogin/index.js"
|
|
2
|
+
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
3
3
|
|
|
4
4
|
export class LoginPage extends PreloginPage {
|
|
5
5
|
socialaccount_providers: Array<Record<string, unknown>>
|
|
@@ -9,7 +9,7 @@ export class LoginPage extends PreloginPage {
|
|
|
9
9
|
language,
|
|
10
10
|
socialaccount_providers
|
|
11
11
|
}: {
|
|
12
|
-
app:
|
|
12
|
+
app: PreloginApp
|
|
13
13
|
language: string
|
|
14
14
|
socialaccount_providers: Array<Record<string, unknown>>
|
|
15
15
|
}) {
|
|
@@ -138,7 +138,7 @@ export class LoginPage extends PreloginPage {
|
|
|
138
138
|
if (errors) {
|
|
139
139
|
return
|
|
140
140
|
}
|
|
141
|
-
return
|
|
141
|
+
return this.app.apiConnectors.auth.login({login, password, remember})
|
|
142
142
|
.catch((response: any) => {
|
|
143
143
|
if (!(response instanceof Response) || response.status !== 400) {
|
|
144
144
|
return Promise.reject(response)
|
|
@@ -181,42 +181,43 @@ export class LoginPage extends PreloginPage {
|
|
|
181
181
|
})
|
|
182
182
|
.then((result: any) => {
|
|
183
183
|
if (!result) return
|
|
184
|
-
const {json, status} = result
|
|
184
|
+
const {json, status, requiresEmailConfirmation} = result
|
|
185
185
|
if (status === 400) {
|
|
186
186
|
return
|
|
187
187
|
}
|
|
188
|
-
this.afterLogin(json)
|
|
188
|
+
this.afterLogin(json, requiresEmailConfirmation)
|
|
189
189
|
})
|
|
190
190
|
})
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
afterLogin(json: any): void {
|
|
193
|
+
afterLogin(json: any, requiresEmailConfirmation?: boolean): void {
|
|
194
194
|
const currentLang = document.documentElement.lang
|
|
195
|
+
if (requiresEmailConfirmation) {
|
|
196
|
+
const contentsEl = document.querySelector(".fw-contents")
|
|
197
|
+
if (contentsEl) {
|
|
198
|
+
contentsEl.innerHTML = `<div class="fw-login-left">
|
|
199
|
+
<h1 class="fw-login-title">${gettext("Verify Your E-mail Address")}</h1>
|
|
200
|
+
<p>
|
|
201
|
+
${gettext("We have sent an e-mail to your email address for verification. Follow the link provided to finalize the signup process.")}
|
|
202
|
+
<br />
|
|
203
|
+
${gettext("Please contact us if you do not receive it within a few minutes.")}
|
|
204
|
+
</p>
|
|
205
|
+
</div>`
|
|
206
|
+
}
|
|
207
|
+
return
|
|
208
|
+
}
|
|
195
209
|
if (json.html && json.html.length > 0) {
|
|
196
210
|
const htmlValues = JSON.parse(json.html)
|
|
197
|
-
|
|
198
|
-
if (htmlValues.Location === "/api/account/confirm-email/") {
|
|
199
|
-
const contentsEl = document.querySelector(".fw-contents")
|
|
200
|
-
if (contentsEl) {
|
|
201
|
-
contentsEl.innerHTML = `<div class="fw-login-left">
|
|
202
|
-
<h1 class="fw-login-title">${gettext("Verify Your E-mail Address")}</h1>
|
|
203
|
-
<p>
|
|
204
|
-
${gettext("We have sent an e-mail to your email address for verification. Follow the link provided to finalize the signup process.")}
|
|
205
|
-
<br />
|
|
206
|
-
${gettext("Please contact us if you do not receive it within a few minutes.")}
|
|
207
|
-
</p>
|
|
208
|
-
</div>`
|
|
209
|
-
}
|
|
210
|
-
} else if (
|
|
211
|
+
if (
|
|
211
212
|
htmlValues.user?.language &&
|
|
212
213
|
htmlValues.user?.language !== currentLang
|
|
213
214
|
) {
|
|
214
215
|
window.location.reload()
|
|
215
216
|
} else {
|
|
216
|
-
|
|
217
|
+
this.app.init()
|
|
217
218
|
}
|
|
218
219
|
} else {
|
|
219
|
-
|
|
220
|
+
this.app.init()
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {escapeText} from "fwtoolkit"
|
|
2
|
-
import {PreloginPage} from "../../prelogin/index.js"
|
|
2
|
+
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
3
3
|
|
|
4
4
|
export class PasswordResetChangePassword extends PreloginPage {
|
|
5
5
|
key: string
|
|
6
6
|
|
|
7
|
-
constructor({app, language}: {app:
|
|
7
|
+
constructor({app, language}: {app: PreloginApp; language: string}, key: string) {
|
|
8
8
|
super({app, language})
|
|
9
9
|
this.title = gettext("Change Password")
|
|
10
10
|
this.key = key
|
|
@@ -76,10 +76,10 @@ export class PasswordResetChangePassword extends PreloginPage {
|
|
|
76
76
|
if (errors) {
|
|
77
77
|
return
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
this.app.apiConnectors.auth
|
|
80
80
|
.passwordResetKeyGet(this.key)
|
|
81
81
|
.then(({url}: {url: string}) =>
|
|
82
|
-
|
|
82
|
+
this.app.apiConnectors.auth.passwordResetKeyPost(
|
|
83
83
|
url,
|
|
84
84
|
{password1, password2}
|
|
85
85
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {escapeText} from "fwtoolkit"
|
|
2
|
-
import {PreloginPage} from "../../prelogin/index.js"
|
|
2
|
+
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
3
3
|
|
|
4
4
|
export class PasswordResetRequest extends PreloginPage {
|
|
5
|
-
constructor({app, language}: {app:
|
|
5
|
+
constructor({app, language}: {app: PreloginApp; language: string}) {
|
|
6
6
|
super({app, language})
|
|
7
7
|
this.title = gettext("Reset Password")
|
|
8
8
|
}
|
|
@@ -66,7 +66,7 @@ export class PasswordResetRequest extends PreloginPage {
|
|
|
66
66
|
return
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
this.app.apiConnectors.auth.passwordReset({email})
|
|
70
70
|
.then(() => {
|
|
71
71
|
if (document.body !== this.dom) {
|
|
72
72
|
return
|
package/src/user/auth/signup.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {escapeText} from "fwtoolkit"
|
|
2
|
-
import {PreloginPage} from "../../prelogin/index.js"
|
|
2
|
+
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
3
3
|
|
|
4
4
|
export class Signup extends PreloginPage {
|
|
5
|
-
constructor({app, language}: {app:
|
|
5
|
+
constructor({app, language}: {app: PreloginApp; language: string}) {
|
|
6
6
|
super({app, language})
|
|
7
7
|
this.title = gettext("Signup")
|
|
8
8
|
if (this.app.settings?.REGISTRATION_OPEN) {
|
|
@@ -126,12 +126,12 @@ export class Signup extends PreloginPage {
|
|
|
126
126
|
return
|
|
127
127
|
}
|
|
128
128
|
const sendData: Record<string, unknown> = {username, password1, password2, email}
|
|
129
|
-
if (
|
|
130
|
-
sendData["invite_key"] =
|
|
129
|
+
if (this.app.inviteKey) {
|
|
130
|
+
sendData["invite_key"] = this.app.inviteKey
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
.then(({
|
|
134
|
-
if (
|
|
132
|
+
this.app.apiConnectors.auth.signup(sendData)
|
|
133
|
+
.then(({requiresEmailConfirmation}) => {
|
|
134
|
+
if (requiresEmailConfirmation) {
|
|
135
135
|
fwContents.innerHTML = `<div class="fw-login-left">
|
|
136
136
|
<h1 class="fw-login-title">${gettext("Verify Your E-mail Address")}</h1>
|
|
137
137
|
<p>
|
|
@@ -150,7 +150,7 @@ export class Signup extends PreloginPage {
|
|
|
150
150
|
</div>`
|
|
151
151
|
} else {
|
|
152
152
|
window.history.pushState({}, "", "/")
|
|
153
|
-
|
|
153
|
+
this.app.init()
|
|
154
154
|
}
|
|
155
155
|
})
|
|
156
156
|
.catch((response: any) =>
|
|
@@ -2,21 +2,30 @@ import {
|
|
|
2
2
|
Dialog,
|
|
3
3
|
activateWait,
|
|
4
4
|
addAlert,
|
|
5
|
-
deactivateWait
|
|
5
|
+
deactivateWait,
|
|
6
|
+
type DialogButtonSpec
|
|
6
7
|
} from "fwtoolkit"
|
|
7
8
|
import QRCode from "qrcode"
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import type {
|
|
10
|
+
TwoFactorSetupResponse,
|
|
11
|
+
TwoFactorStatusResponse,
|
|
12
|
+
TwoFactorVerifyResponse
|
|
13
|
+
} from "../../api/index.js"
|
|
14
|
+
import type {FrontendApp} from "../../types.js"
|
|
15
|
+
import type {LoginPage} from "./login.js"
|
|
16
|
+
|
|
17
|
+
export const twoFactorSetupDialog = (app: FrontendApp): Promise<any> => {
|
|
10
18
|
let secretKey: string | null = null
|
|
11
19
|
let deviceId: string | null = null
|
|
12
20
|
|
|
13
21
|
activateWait()
|
|
14
|
-
return app.apiConnectors.auth.twoFactorSetup().then((json:
|
|
22
|
+
return app.apiConnectors.auth.twoFactorSetup().then((json: TwoFactorSetupResponse): any => {
|
|
15
23
|
deactivateWait()
|
|
16
24
|
|
|
17
25
|
if (json.status !== "success") {
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
const message = json.message || gettext("Two-factor setup failed.")
|
|
27
|
+
addAlert("error", message)
|
|
28
|
+
return Promise.reject(message)
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
secretKey = json.secret_key
|
|
@@ -46,7 +55,7 @@ export const twoFactorSetupDialog = (app: any): Promise<any> => {
|
|
|
46
55
|
}
|
|
47
56
|
)
|
|
48
57
|
|
|
49
|
-
const buttons = [
|
|
58
|
+
const buttons: DialogButtonSpec[] = [
|
|
50
59
|
{
|
|
51
60
|
text: gettext("Verify"),
|
|
52
61
|
classes: "fw-dark",
|
|
@@ -65,7 +74,7 @@ export const twoFactorSetupDialog = (app: any): Promise<any> => {
|
|
|
65
74
|
code,
|
|
66
75
|
device_id: deviceId
|
|
67
76
|
})
|
|
68
|
-
.then((json:
|
|
77
|
+
.then((json: TwoFactorVerifyResponse) => {
|
|
69
78
|
if (json.status === "success") {
|
|
70
79
|
addAlert("success", json.message)
|
|
71
80
|
dialog.close()
|
|
@@ -98,7 +107,7 @@ export const twoFactorSetupDialog = (app: any): Promise<any> => {
|
|
|
98
107
|
buttons,
|
|
99
108
|
icon: "shield-alt",
|
|
100
109
|
width: 500
|
|
101
|
-
}
|
|
110
|
+
})
|
|
102
111
|
|
|
103
112
|
dialog.open()
|
|
104
113
|
|
|
@@ -112,22 +121,22 @@ export const twoFactorSetupDialog = (app: any): Promise<any> => {
|
|
|
112
121
|
;(codeInput as HTMLElement).addEventListener("keypress", (event: Event) => {
|
|
113
122
|
if ((event as KeyboardEvent).key === "Enter") {
|
|
114
123
|
event.preventDefault()
|
|
115
|
-
|
|
124
|
+
buttons[0].click!()
|
|
116
125
|
}
|
|
117
126
|
})
|
|
118
127
|
}
|
|
119
128
|
})
|
|
120
129
|
}
|
|
121
130
|
|
|
122
|
-
export const twoFactorDisableDialog = (app:
|
|
123
|
-
const buttons = [
|
|
131
|
+
export const twoFactorDisableDialog = (app: FrontendApp): any => {
|
|
132
|
+
const buttons: DialogButtonSpec[] = [
|
|
124
133
|
{
|
|
125
134
|
text: gettext("Disable 2FA"),
|
|
126
135
|
classes: "fw-orange",
|
|
127
136
|
click: () => {
|
|
128
137
|
activateWait()
|
|
129
138
|
app.apiConnectors.auth.twoFactorDisable()
|
|
130
|
-
.then((json:
|
|
139
|
+
.then((json: TwoFactorVerifyResponse) => {
|
|
131
140
|
if (json.status === "success") {
|
|
132
141
|
addAlert("success", json.message)
|
|
133
142
|
dialog.close()
|
|
@@ -156,7 +165,7 @@ export const twoFactorDisableDialog = (app: any): any => {
|
|
|
156
165
|
body: `<p>${gettext("Are you sure you want to disable two-factor authentication? This will reduce the security of your account.")}</p>`,
|
|
157
166
|
buttons,
|
|
158
167
|
icon: "exclamation-triangle"
|
|
159
|
-
}
|
|
168
|
+
})
|
|
160
169
|
|
|
161
170
|
dialog.open()
|
|
162
171
|
return dialog
|
|
@@ -172,10 +181,10 @@ export const twoFactorLoginDialog = ({
|
|
|
172
181
|
login: string
|
|
173
182
|
password: string
|
|
174
183
|
remember: boolean
|
|
175
|
-
loginPage:
|
|
176
|
-
app:
|
|
184
|
+
loginPage: LoginPage
|
|
185
|
+
app: FrontendApp
|
|
177
186
|
}): any => {
|
|
178
|
-
const buttons = [
|
|
187
|
+
const buttons: DialogButtonSpec[] = [
|
|
179
188
|
{
|
|
180
189
|
text: gettext("Verify"),
|
|
181
190
|
classes: "fw-dark",
|
|
@@ -197,7 +206,7 @@ export const twoFactorLoginDialog = ({
|
|
|
197
206
|
remember,
|
|
198
207
|
twofactor
|
|
199
208
|
})
|
|
200
|
-
.then((json:
|
|
209
|
+
.then((json: TwoFactorVerifyResponse) => {
|
|
201
210
|
deactivateWait()
|
|
202
211
|
dialog.close()
|
|
203
212
|
loginPage.afterLogin(json)
|
|
@@ -218,7 +227,7 @@ export const twoFactorLoginDialog = ({
|
|
|
218
227
|
buttons,
|
|
219
228
|
icon: "shield-alt",
|
|
220
229
|
width: 500
|
|
221
|
-
}
|
|
230
|
+
})
|
|
222
231
|
|
|
223
232
|
dialog.open()
|
|
224
233
|
const codeInput = dialog.dialogEl.querySelector("#two-factor-code")
|
|
@@ -226,16 +235,16 @@ export const twoFactorLoginDialog = ({
|
|
|
226
235
|
;(codeInput as HTMLElement).addEventListener("keypress", (event: Event) => {
|
|
227
236
|
if ((event as KeyboardEvent).key === "Enter") {
|
|
228
237
|
event.preventDefault()
|
|
229
|
-
buttons[0].click()
|
|
238
|
+
buttons[0].click!()
|
|
230
239
|
}
|
|
231
240
|
})
|
|
232
241
|
}
|
|
233
242
|
return dialog
|
|
234
243
|
}
|
|
235
244
|
|
|
236
|
-
export const checkTwoFactorStatus = (app:
|
|
245
|
+
export const checkTwoFactorStatus = (app: FrontendApp): Promise<boolean> => {
|
|
237
246
|
return app.apiConnectors.auth.twoFactorStatus()
|
|
238
|
-
.then((json:
|
|
247
|
+
.then((json: TwoFactorStatusResponse) => {
|
|
239
248
|
if (json.status === "success") {
|
|
240
249
|
return json.enabled
|
|
241
250
|
}
|
|
@@ -3,11 +3,14 @@ import {addContactTemplate} from "./templates.js"
|
|
|
3
3
|
|
|
4
4
|
export class AddContactDialog {
|
|
5
5
|
settings: Record<string, unknown>
|
|
6
|
-
|
|
6
|
+
contactsApi: {add(data: {user_string: string}): Promise<{json: unknown; status: number}>}
|
|
7
7
|
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(
|
|
9
|
+
settings: Record<string, unknown>,
|
|
10
|
+
contactsApi: {add(data: {user_string: string}): Promise<{json: unknown; status: number}>}
|
|
11
|
+
) {
|
|
9
12
|
this.settings = settings
|
|
10
|
-
this.
|
|
13
|
+
this.contactsApi = contactsApi
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
init(): Promise<Array<Record<string, unknown>>> {
|
|
@@ -78,7 +81,7 @@ export class AddContactDialog {
|
|
|
78
81
|
return cancelPromise()
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
return this.
|
|
84
|
+
return this.contactsApi.add({
|
|
82
85
|
user_string: userString
|
|
83
86
|
}).then(({json, status}: any) => {
|
|
84
87
|
if (status == 201) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {Dialog} from "fwtoolkit"
|
|
2
|
+
import type {FrontendApp} from "../../types.js"
|
|
2
3
|
|
|
3
4
|
export class DeleteContactDialog {
|
|
4
5
|
contacts: Array<Record<string, unknown>>
|
|
5
|
-
app:
|
|
6
|
+
app: FrontendApp
|
|
6
7
|
|
|
7
|
-
constructor(contacts: Array<Record<string, unknown>>, app
|
|
8
|
+
constructor(contacts: Array<Record<string, unknown>>, app: FrontendApp) {
|
|
8
9
|
this.contacts = contacts
|
|
9
10
|
this.app = app
|
|
10
11
|
}
|
|
@@ -21,9 +21,19 @@ import {
|
|
|
21
21
|
displayContactType,
|
|
22
22
|
respondInviteCell
|
|
23
23
|
} from "./templates.js"
|
|
24
|
+
import type {ContactsListResponse} from "../../api/index.js"
|
|
25
|
+
import type {FrontendApp} from "../../types.js"
|
|
26
|
+
|
|
27
|
+
export interface ContactsApp extends FrontendApp {
|
|
28
|
+
indexedDB: {
|
|
29
|
+
readAllData: (store: string) => Promise<Array<Record<string, unknown>>>
|
|
30
|
+
clearData: (store: string) => Promise<void>
|
|
31
|
+
insertData: (store: string, data: Array<Record<string, unknown>>) => Promise<void>
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
|
|
25
35
|
export class ContactsOverview {
|
|
26
|
-
app:
|
|
36
|
+
app: ContactsApp
|
|
27
37
|
user: Record<string, unknown>
|
|
28
38
|
contacts: Array<Record<string, unknown>>
|
|
29
39
|
lastSort: {column: number; dir: string}
|
|
@@ -33,7 +43,7 @@ export class ContactsOverview {
|
|
|
33
43
|
dtBulk: any
|
|
34
44
|
menu: any
|
|
35
45
|
|
|
36
|
-
constructor({app, user}: {app:
|
|
46
|
+
constructor({app, user}: {app: ContactsApp; user: Record<string, unknown>}) {
|
|
37
47
|
this.app = app
|
|
38
48
|
this.user = user
|
|
39
49
|
this.contacts = []
|
|
@@ -168,8 +178,8 @@ export class ContactsOverview {
|
|
|
168
178
|
if (this.app.isOffline()) {
|
|
169
179
|
return cachedPromise.then(() => {})
|
|
170
180
|
}
|
|
171
|
-
return
|
|
172
|
-
.then((json:
|
|
181
|
+
return this.app.apiConnectors.contacts.list()
|
|
182
|
+
.then((json: ContactsListResponse) => {
|
|
173
183
|
return cachedPromise.then(oldJson => {
|
|
174
184
|
if (!deepEqual(json, oldJson)) {
|
|
175
185
|
this.updateIndexedDB(json)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type {ContactsInviteResponse} from "../../api/index.js"
|
|
2
|
+
import type {PreloginApp} from "../../prelogin/index.js"
|
|
3
|
+
|
|
1
4
|
export class ContactInvite {
|
|
2
|
-
app:
|
|
5
|
+
app: PreloginApp
|
|
3
6
|
key: string
|
|
4
7
|
|
|
5
|
-
constructor({app}: {app:
|
|
8
|
+
constructor({app}: {app: PreloginApp}, key: string) {
|
|
6
9
|
this.app = app
|
|
7
10
|
this.key = key
|
|
8
11
|
}
|
|
@@ -10,11 +13,12 @@ export class ContactInvite {
|
|
|
10
13
|
init(): Promise<any> {
|
|
11
14
|
if (!this.app.config.user.is_authenticated) {
|
|
12
15
|
this.app.inviteKey = this.key
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const loginPage = this.app.openLoginPage()
|
|
17
|
+
this.app.page = loginPage
|
|
18
|
+
return loginPage.init()
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
return this.app.apiConnectors.contacts.invite({key: this.key}).then((json:
|
|
21
|
+
return this.app.apiConnectors.contacts.invite({key: this.key}).then((json: ContactsInviteResponse) => {
|
|
18
22
|
window.history.replaceState({}, "", json.redirect)
|
|
19
23
|
return this.app.selectPage()
|
|
20
24
|
})
|
|
@@ -37,7 +37,10 @@ export const menuModel = (): {content: Array<Record<string, unknown>>} => ({
|
|
|
37
37
|
title: gettext("Invite contact"),
|
|
38
38
|
keys: "Alt-i",
|
|
39
39
|
action: (overview: any) => {
|
|
40
|
-
const dialog = new AddContactDialog(
|
|
40
|
+
const dialog = new AddContactDialog(
|
|
41
|
+
overview.app.settings,
|
|
42
|
+
overview.app.apiConnectors.contacts
|
|
43
|
+
)
|
|
41
44
|
dialog.init().then((contacts: any) => {
|
|
42
45
|
contacts.forEach((contact: any) => overview.contacts.push(contact))
|
|
43
46
|
overview.initializeView()
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import {Dialog, escapeText} from "fwtoolkit"
|
|
2
|
+
import type {FrontendApp} from "../../types.js"
|
|
2
3
|
|
|
3
4
|
export class RespondInviteDialog {
|
|
4
5
|
invites: Array<Record<string, unknown>>
|
|
5
6
|
addCallback: (contacts: Array<Record<string, unknown>>) => void
|
|
6
7
|
deleteCallback: (invites: Array<Record<string, unknown>>) => void
|
|
7
8
|
doneCallback: () => void
|
|
8
|
-
app:
|
|
9
|
+
app: FrontendApp
|
|
9
10
|
|
|
10
11
|
constructor(
|
|
11
12
|
invites: Array<Record<string, unknown>>,
|
|
12
13
|
addCallback: (contacts: Array<Record<string, unknown>>) => void = () => {},
|
|
13
14
|
deleteCallback: (invites: Array<Record<string, unknown>>) => void = () => {},
|
|
14
15
|
doneCallback: () => void = () => {},
|
|
15
|
-
app
|
|
16
|
+
app: FrontendApp
|
|
16
17
|
) {
|
|
17
18
|
this.invites = invites
|
|
18
19
|
this.addCallback = addCallback
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {Dialog, activateWait, addAlert, deactivateWait} from "fwtoolkit"
|
|
2
|
+
import type {FrontendApp} from "../../types.js"
|
|
2
3
|
import {deleteUserDialogTemplate} from "./templates.js"
|
|
3
4
|
|
|
4
5
|
export class DeleteUserDialog {
|
|
5
6
|
username: string
|
|
6
|
-
app:
|
|
7
|
+
app: FrontendApp
|
|
7
8
|
dialog: any
|
|
8
9
|
|
|
9
|
-
constructor(username: string, app:
|
|
10
|
+
constructor(username: string, app: FrontendApp) {
|
|
10
11
|
this.username = username
|
|
11
12
|
this.app = app
|
|
12
13
|
}
|