@fiduswriter/frontend 0.1.9
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/LICENSE +661 -0
- package/README.md +66 -0
- package/dist/admin_console/index.d.ts +8 -0
- package/dist/admin_console/index.d.ts.map +1 -0
- package/dist/admin_console/index.js +54 -0
- package/dist/admin_console/index.js.map +1 -0
- package/dist/api/index.d.ts +193 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -0
- package/dist/app/index.d.ts +74 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +471 -0
- package/dist/app/index.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/templates.d.ts +3 -0
- package/dist/common/templates.d.ts.map +1 -0
- package/dist/common/templates.js +42 -0
- package/dist/common/templates.js.map +1 -0
- package/dist/common/user_util.d.ts +6 -0
- package/dist/common/user_util.d.ts.map +1 -0
- package/dist/common/user_util.js +16 -0
- package/dist/common/user_util.js.map +1 -0
- package/dist/document_templates/actions.d.ts +11 -0
- package/dist/document_templates/actions.d.ts.map +1 -0
- package/dist/document_templates/actions.js +141 -0
- package/dist/document_templates/actions.js.map +1 -0
- package/dist/document_templates/editor.d.ts +28 -0
- package/dist/document_templates/editor.d.ts.map +1 -0
- package/dist/document_templates/editor.js +139 -0
- package/dist/document_templates/editor.js.map +1 -0
- package/dist/document_templates/index.d.ts +3 -0
- package/dist/document_templates/index.d.ts.map +1 -0
- package/dist/document_templates/index.js +3 -0
- package/dist/document_templates/index.js.map +1 -0
- package/dist/document_templates/menu.d.ts +7 -0
- package/dist/document_templates/menu.d.ts.map +1 -0
- package/dist/document_templates/menu.js +62 -0
- package/dist/document_templates/menu.js.map +1 -0
- package/dist/document_templates/overview.d.ts +52 -0
- package/dist/document_templates/overview.d.ts.map +1 -0
- package/dist/document_templates/overview.js +274 -0
- package/dist/document_templates/overview.js.map +1 -0
- package/dist/document_templates/templates.d.ts +3 -0
- package/dist/document_templates/templates.d.ts.map +1 -0
- package/dist/document_templates/templates.js +9 -0
- package/dist/document_templates/templates.js.map +1 -0
- package/dist/documents/importer/docx/import.d.ts +5 -0
- package/dist/documents/importer/docx/import.d.ts.map +1 -0
- package/dist/documents/importer/docx/import.js +15 -0
- package/dist/documents/importer/docx/import.js.map +1 -0
- package/dist/documents/importer/docx/index.d.ts +2 -0
- package/dist/documents/importer/docx/index.d.ts.map +1 -0
- package/dist/documents/importer/docx/index.js +2 -0
- package/dist/documents/importer/docx/index.js.map +1 -0
- package/dist/documents/importer/native/file.d.ts +7 -0
- package/dist/documents/importer/native/file.d.ts.map +1 -0
- package/dist/documents/importer/native/file.js +60 -0
- package/dist/documents/importer/native/file.js.map +1 -0
- package/dist/documents/importer/native/import.d.ts +41 -0
- package/dist/documents/importer/native/import.d.ts.map +1 -0
- package/dist/documents/importer/native/import.js +126 -0
- package/dist/documents/importer/native/import.js.map +1 -0
- package/dist/documents/importer/native/index.d.ts +3 -0
- package/dist/documents/importer/native/index.d.ts.map +1 -0
- package/dist/documents/importer/native/index.js +3 -0
- package/dist/documents/importer/native/index.js.map +1 -0
- package/dist/documents/importer/odt/import.d.ts +5 -0
- package/dist/documents/importer/odt/import.d.ts.map +1 -0
- package/dist/documents/importer/odt/import.js +16 -0
- package/dist/documents/importer/odt/import.js.map +1 -0
- package/dist/documents/importer/odt/index.d.ts +2 -0
- package/dist/documents/importer/odt/index.d.ts.map +1 -0
- package/dist/documents/importer/odt/index.js +2 -0
- package/dist/documents/importer/odt/index.js.map +1 -0
- package/dist/documents/importer/pandoc/import.d.ts +5 -0
- package/dist/documents/importer/pandoc/import.d.ts.map +1 -0
- package/dist/documents/importer/pandoc/import.js +37 -0
- package/dist/documents/importer/pandoc/import.js.map +1 -0
- package/dist/documents/importer/pandoc/index.d.ts +2 -0
- package/dist/documents/importer/pandoc/index.d.ts.map +1 -0
- package/dist/documents/importer/pandoc/index.js +2 -0
- package/dist/documents/importer/pandoc/index.js.map +1 -0
- package/dist/documents/importer/register.d.ts +4 -0
- package/dist/documents/importer/register.d.ts.map +1 -0
- package/dist/documents/importer/register.js +4 -0
- package/dist/documents/importer/register.js.map +1 -0
- package/dist/documents/overview/actions.d.ts +32 -0
- package/dist/documents/overview/actions.d.ts.map +1 -0
- package/dist/documents/overview/actions.js +725 -0
- package/dist/documents/overview/actions.js.map +1 -0
- package/dist/documents/overview/index.d.ts +98 -0
- package/dist/documents/overview/index.d.ts.map +1 -0
- package/dist/documents/overview/index.js +814 -0
- package/dist/documents/overview/index.js.map +1 -0
- package/dist/documents/overview/menu.d.ts +28 -0
- package/dist/documents/overview/menu.d.ts.map +1 -0
- package/dist/documents/overview/menu.js +222 -0
- package/dist/documents/overview/menu.js.map +1 -0
- package/dist/documents/overview/templates.d.ts +31 -0
- package/dist/documents/overview/templates.d.ts.map +1 -0
- package/dist/documents/overview/templates.js +39 -0
- package/dist/documents/overview/templates.js.map +1 -0
- package/dist/documents/revisions/index.d.ts +14 -0
- package/dist/documents/revisions/index.d.ts.map +1 -0
- package/dist/documents/revisions/index.js +143 -0
- package/dist/documents/revisions/index.js.map +1 -0
- package/dist/documents/revisions/templates.d.ts +4 -0
- package/dist/documents/revisions/templates.d.ts.map +1 -0
- package/dist/documents/revisions/templates.js +36 -0
- package/dist/documents/revisions/templates.js.map +1 -0
- package/dist/documents/tools.d.ts +16 -0
- package/dist/documents/tools.d.ts.map +1 -0
- package/dist/documents/tools.js +69 -0
- package/dist/documents/tools.js.map +1 -0
- package/dist/error_hook/index.d.ts +19 -0
- package/dist/error_hook/index.d.ts.map +1 -0
- package/dist/error_hook/index.js +75 -0
- package/dist/error_hook/index.js.map +1 -0
- package/dist/feedback/index.d.ts +12 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +125 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/indexed_db/index.d.ts +24 -0
- package/dist/indexed_db/index.d.ts.map +1 -0
- package/dist/indexed_db/index.js +175 -0
- package/dist/indexed_db/index.js.map +1 -0
- package/dist/maintenance/index.d.ts +19 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +223 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/menu/index.d.ts +25 -0
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/menu/index.js +229 -0
- package/dist/menu/index.js.map +1 -0
- package/dist/menu/templates.d.ts +6 -0
- package/dist/menu/templates.d.ts.map +1 -0
- package/dist/menu/templates.js +10 -0
- package/dist/menu/templates.js.map +1 -0
- package/dist/pages/404.d.ts +9 -0
- package/dist/pages/404.d.ts.map +1 -0
- package/dist/pages/404.js +12 -0
- package/dist/pages/404.js.map +1 -0
- package/dist/pages/flatpage.d.ts +12 -0
- package/dist/pages/flatpage.d.ts.map +1 -0
- package/dist/pages/flatpage.js +39 -0
- package/dist/pages/flatpage.js.map +1 -0
- package/dist/pages/offline.d.ts +10 -0
- package/dist/pages/offline.d.ts.map +1 -0
- package/dist/pages/offline.js +27 -0
- package/dist/pages/offline.js.map +1 -0
- package/dist/pages/setup.d.ts +10 -0
- package/dist/pages/setup.d.ts.map +1 -0
- package/dist/pages/setup.js +22 -0
- package/dist/pages/setup.js.map +1 -0
- package/dist/plugins/menu/index.d.ts +3 -0
- package/dist/plugins/menu/index.d.ts.map +1 -0
- package/dist/plugins/menu/index.js +2 -0
- package/dist/plugins/menu/index.js.map +1 -0
- package/dist/prelogin/index.d.ts +51 -0
- package/dist/prelogin/index.d.ts.map +1 -0
- package/dist/prelogin/index.js +131 -0
- package/dist/prelogin/index.js.map +1 -0
- package/dist/prelogin/templates.d.ts +20 -0
- package/dist/prelogin/templates.d.ts.map +1 -0
- package/dist/prelogin/templates.js +50 -0
- package/dist/prelogin/templates.js.map +1 -0
- package/dist/state_plugins/contributor_input/add_button.d.ts +22 -0
- package/dist/state_plugins/contributor_input/add_button.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/add_button.js +106 -0
- package/dist/state_plugins/contributor_input/add_button.js.map +1 -0
- package/dist/state_plugins/contributor_input/helpers.d.ts +3 -0
- package/dist/state_plugins/contributor_input/helpers.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/helpers.js +23 -0
- package/dist/state_plugins/contributor_input/helpers.js.map +1 -0
- package/dist/state_plugins/contributor_input/index.d.ts +4 -0
- package/dist/state_plugins/contributor_input/index.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/index.js +4 -0
- package/dist/state_plugins/contributor_input/index.js.map +1 -0
- package/dist/state_plugins/contributor_input/node_view.d.ts +20 -0
- package/dist/state_plugins/contributor_input/node_view.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/node_view.js +85 -0
- package/dist/state_plugins/contributor_input/node_view.js.map +1 -0
- package/dist/state_plugins/index.d.ts +3 -0
- package/dist/state_plugins/index.d.ts.map +1 -0
- package/dist/state_plugins/index.js +3 -0
- package/dist/state_plugins/index.js.map +1 -0
- package/dist/state_plugins/tag_input/helpers.d.ts +5 -0
- package/dist/state_plugins/tag_input/helpers.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/helpers.js +55 -0
- package/dist/state_plugins/tag_input/helpers.js.map +1 -0
- package/dist/state_plugins/tag_input/index.d.ts +5 -0
- package/dist/state_plugins/tag_input/index.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/index.js +5 -0
- package/dist/state_plugins/tag_input/index.js.map +1 -0
- package/dist/state_plugins/tag_input/node_view.d.ts +19 -0
- package/dist/state_plugins/tag_input/node_view.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/node_view.js +85 -0
- package/dist/state_plugins/tag_input/node_view.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor.d.ts +4 -0
- package/dist/state_plugins/tag_input/tag_editor.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor.js +160 -0
- package/dist/state_plugins/tag_input/tag_editor.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts +5 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js +64 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/user/auth/email_confirm.d.ts +23 -0
- package/dist/user/auth/email_confirm.d.ts.map +1 -0
- package/dist/user/auth/email_confirm.js +123 -0
- package/dist/user/auth/email_confirm.js.map +1 -0
- package/dist/user/auth/email_confirm_templates.d.ts +12 -0
- package/dist/user/auth/email_confirm_templates.d.ts.map +1 -0
- package/dist/user/auth/email_confirm_templates.js +30 -0
- package/dist/user/auth/email_confirm_templates.js.map +1 -0
- package/dist/user/auth/login.d.ts +13 -0
- package/dist/user/auth/login.d.ts.map +1 -0
- package/dist/user/auth/login.js +186 -0
- package/dist/user/auth/login.js.map +1 -0
- package/dist/user/auth/password_reset_change.d.ts +11 -0
- package/dist/user/auth/password_reset_change.d.ts.map +1 -0
- package/dist/user/auth/password_reset_change.js +101 -0
- package/dist/user/auth/password_reset_change.js.map +1 -0
- package/dist/user/auth/password_reset_request.d.ts +10 -0
- package/dist/user/auth/password_reset_request.d.ts.map +1 -0
- package/dist/user/auth/password_reset_request.js +82 -0
- package/dist/user/auth/password_reset_request.js.map +1 -0
- package/dist/user/auth/signup.d.ts +9 -0
- package/dist/user/auth/signup.d.ts.map +1 -0
- package/dist/user/auth/signup.js +148 -0
- package/dist/user/auth/signup.js.map +1 -0
- package/dist/user/auth/two_factor.d.ts +10 -0
- package/dist/user/auth/two_factor.d.ts.map +1 -0
- package/dist/user/auth/two_factor.js +201 -0
- package/dist/user/auth/two_factor.js.map +1 -0
- package/dist/user/contacts/add_dialog.d.ts +7 -0
- package/dist/user/contacts/add_dialog.d.ts.map +1 -0
- package/dist/user/contacts/add_dialog.js +84 -0
- package/dist/user/contacts/add_dialog.js.map +1 -0
- package/dist/user/contacts/delete_dialog.d.ts +6 -0
- package/dist/user/contacts/delete_dialog.d.ts.map +1 -0
- package/dist/user/contacts/delete_dialog.js +38 -0
- package/dist/user/contacts/delete_dialog.js.map +1 -0
- package/dist/user/contacts/index.d.ts +35 -0
- package/dist/user/contacts/index.d.ts.map +1 -0
- package/dist/user/contacts/index.js +234 -0
- package/dist/user/contacts/index.js.map +1 -0
- package/dist/user/contacts/invite.d.ts +9 -0
- package/dist/user/contacts/invite.d.ts.map +1 -0
- package/dist/user/contacts/invite.js +21 -0
- package/dist/user/contacts/invite.js.map +1 -0
- package/dist/user/contacts/menu.d.ts +7 -0
- package/dist/user/contacts/menu.d.ts.map +1 -0
- package/dist/user/contacts/menu.js +62 -0
- package/dist/user/contacts/menu.js.map +1 -0
- package/dist/user/contacts/respond_invite.d.ts +9 -0
- package/dist/user/contacts/respond_invite.d.ts.map +1 -0
- package/dist/user/contacts/respond_invite.js +65 -0
- package/dist/user/contacts/respond_invite.js.map +1 -0
- package/dist/user/contacts/templates.d.ts +7 -0
- package/dist/user/contacts/templates.d.ts.map +1 -0
- package/dist/user/contacts/templates.js +24 -0
- package/dist/user/contacts/templates.js.map +1 -0
- package/dist/user/profile/delete_user.d.ts +8 -0
- package/dist/user/profile/delete_user.d.ts.map +1 -0
- package/dist/user/profile/delete_user.js +56 -0
- package/dist/user/profile/delete_user.js.map +1 -0
- package/dist/user/profile/dialogs.d.ts +10 -0
- package/dist/user/profile/dialogs.d.ts.map +1 -0
- package/dist/user/profile/dialogs.js +311 -0
- package/dist/user/profile/dialogs.js.map +1 -0
- package/dist/user/profile/index.d.ts +27 -0
- package/dist/user/profile/index.d.ts.map +1 -0
- package/dist/user/profile/index.js +254 -0
- package/dist/user/profile/index.js.map +1 -0
- package/dist/user/profile/templates.d.ts +22 -0
- package/dist/user/profile/templates.d.ts.map +1 -0
- package/dist/user/profile/templates.js +261 -0
- package/dist/user/profile/templates.js.map +1 -0
- package/dist/workers/adjust_doc_to_template.d.ts +11 -0
- package/dist/workers/adjust_doc_to_template.d.ts.map +1 -0
- package/dist/workers/adjust_doc_to_template.js +26 -0
- package/dist/workers/adjust_doc_to_template.js.map +1 -0
- package/package.json +225 -0
- package/src/admin_console/index.ts +84 -0
- package/src/api/index.ts +149 -0
- package/src/app/index.ts +605 -0
- package/src/common/index.ts +2 -0
- package/src/common/templates.ts +49 -0
- package/src/common/user_util.ts +16 -0
- package/src/document_templates/actions.ts +179 -0
- package/src/document_templates/editor.ts +177 -0
- package/src/document_templates/index.ts +2 -0
- package/src/document_templates/menu.ts +74 -0
- package/src/document_templates/overview.ts +335 -0
- package/src/document_templates/templates.ts +9 -0
- package/src/documents/importer/docx/import.ts +25 -0
- package/src/documents/importer/docx/index.ts +1 -0
- package/src/documents/importer/native/file.ts +112 -0
- package/src/documents/importer/native/import.ts +219 -0
- package/src/documents/importer/native/index.ts +2 -0
- package/src/documents/importer/odt/import.ts +26 -0
- package/src/documents/importer/odt/index.ts +1 -0
- package/src/documents/importer/pandoc/import.ts +57 -0
- package/src/documents/importer/pandoc/index.ts +1 -0
- package/src/documents/importer/register.ts +8 -0
- package/src/documents/overview/actions.ts +1031 -0
- package/src/documents/overview/index.ts +1006 -0
- package/src/documents/overview/menu.ts +311 -0
- package/src/documents/overview/templates.ts +64 -0
- package/src/documents/revisions/index.ts +183 -0
- package/src/documents/revisions/templates.ts +42 -0
- package/src/documents/tools.ts +107 -0
- package/src/error_hook/index.ts +129 -0
- package/src/feedback/index.ts +185 -0
- package/src/global.d.ts +22 -0
- package/src/index.ts +95 -0
- package/src/indexed_db/index.ts +217 -0
- package/src/maintenance/index.ts +258 -0
- package/src/menu/index.ts +267 -0
- package/src/menu/templates.ts +21 -0
- package/src/pages/404.ts +13 -0
- package/src/pages/flatpage.ts +43 -0
- package/src/pages/offline.ts +39 -0
- package/src/pages/setup.ts +34 -0
- package/src/plugins/menu/index.ts +3 -0
- package/src/prelogin/index.ts +175 -0
- package/src/prelogin/templates.ts +86 -0
- package/src/types.ts +63 -0
- package/src/user/auth/email_confirm.ts +153 -0
- package/src/user/auth/email_confirm_templates.ts +76 -0
- package/src/user/auth/login.ts +221 -0
- package/src/user/auth/password_reset_change.ts +120 -0
- package/src/user/auth/password_reset_request.ts +107 -0
- package/src/user/auth/signup.ts +182 -0
- package/src/user/auth/two_factor.ts +244 -0
- package/src/user/contacts/add_dialog.ts +104 -0
- package/src/user/contacts/delete_dialog.ts +40 -0
- package/src/user/contacts/index.ts +289 -0
- package/src/user/contacts/invite.ts +24 -0
- package/src/user/contacts/menu.ts +70 -0
- package/src/user/contacts/respond_invite.ts +76 -0
- package/src/user/contacts/templates.ts +29 -0
- package/src/user/profile/delete_user.ts +71 -0
- package/src/user/profile/dialogs.ts +363 -0
- package/src/user/profile/index.ts +359 -0
- package/src/user/profile/templates.ts +299 -0
- package/src/workers/adjust_doc_to_template.ts +41 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface Email {
|
|
2
|
+
address: string
|
|
3
|
+
primary?: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface User {
|
|
7
|
+
username: string
|
|
8
|
+
emails: Email[]
|
|
9
|
+
name?: string
|
|
10
|
+
avatar?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Route {
|
|
14
|
+
app: string
|
|
15
|
+
[key: string]: unknown
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type RouteMap = Record<string, Route>
|
|
19
|
+
|
|
20
|
+
export interface Settings {
|
|
21
|
+
APPS: string[]
|
|
22
|
+
[key: string]: unknown
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SiteMenuLike {
|
|
26
|
+
app: App
|
|
27
|
+
navItems: NavItem[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NavItem {
|
|
31
|
+
text: string
|
|
32
|
+
url: string
|
|
33
|
+
title: string
|
|
34
|
+
id: string
|
|
35
|
+
order: number
|
|
36
|
+
keys?: string
|
|
37
|
+
active?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface MenuPluginExport {
|
|
41
|
+
new (siteMenu: SiteMenuLike): {init(): void}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type MenuPlugin = Record<string, MenuPluginExport>
|
|
45
|
+
|
|
46
|
+
export type MenuPlugins = Array<[string, MenuPlugin]>
|
|
47
|
+
|
|
48
|
+
export interface App {
|
|
49
|
+
routes: RouteMap
|
|
50
|
+
goTo: (url: string) => void
|
|
51
|
+
settings: Settings
|
|
52
|
+
menuPlugins?: MenuPlugins
|
|
53
|
+
name?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface BaseBodyTemplateOptions {
|
|
57
|
+
user: User
|
|
58
|
+
contents: string
|
|
59
|
+
hasOverview?: boolean
|
|
60
|
+
app: App
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activateWait,
|
|
3
|
+
addAlert,
|
|
4
|
+
deactivateWait,
|
|
5
|
+
post,
|
|
6
|
+
postJson,
|
|
7
|
+
whenReady
|
|
8
|
+
} from "fwtoolkit"
|
|
9
|
+
import {PreloginPage} from "../../prelogin/index.js"
|
|
10
|
+
import {
|
|
11
|
+
checkTermsTemplate,
|
|
12
|
+
confirmAccountTemplate,
|
|
13
|
+
testServerQuestionTemplate,
|
|
14
|
+
verifiedAccountTemplate
|
|
15
|
+
} from "./email_confirm_templates.js"
|
|
16
|
+
|
|
17
|
+
export class EmailConfirm extends PreloginPage {
|
|
18
|
+
key: string
|
|
19
|
+
validKey: boolean
|
|
20
|
+
loggedIn: boolean
|
|
21
|
+
verified: boolean
|
|
22
|
+
username: string
|
|
23
|
+
email: string
|
|
24
|
+
submissionReady: boolean
|
|
25
|
+
formChecks: Array<() => boolean>
|
|
26
|
+
confirmQuestionsTemplates: Array<() => string>
|
|
27
|
+
confirmMethods: Array<() => Promise<unknown>>
|
|
28
|
+
firstVerification: boolean
|
|
29
|
+
|
|
30
|
+
constructor({app, language}: {app: any; language: string}, key: string) {
|
|
31
|
+
super({app, language})
|
|
32
|
+
|
|
33
|
+
this.title = gettext("Confirm Email")
|
|
34
|
+
this.pluginLoaders = []
|
|
35
|
+
|
|
36
|
+
this.key = key
|
|
37
|
+
|
|
38
|
+
this.validKey = false
|
|
39
|
+
this.loggedIn = false
|
|
40
|
+
this.verified = false
|
|
41
|
+
this.username = ""
|
|
42
|
+
this.email = ""
|
|
43
|
+
|
|
44
|
+
this.submissionReady = false
|
|
45
|
+
this.formChecks = []
|
|
46
|
+
this.confirmQuestionsTemplates = []
|
|
47
|
+
this.confirmMethods = [
|
|
48
|
+
() => post(`/api/user/confirm-email/${this.key}/`)
|
|
49
|
+
]
|
|
50
|
+
this.firstVerification = false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
init(): Promise<void> {
|
|
54
|
+
return Promise.all([whenReady(), this.getConfirmData()]).then(() => {
|
|
55
|
+
this.activateFidusPlugins()
|
|
56
|
+
this.render()
|
|
57
|
+
this.bind()
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getConfirmData(): Promise<void> {
|
|
62
|
+
return postJson("/api/user/get_confirmkey_data/", {key: this.key})
|
|
63
|
+
.then(({json}: any) => {
|
|
64
|
+
this.username = json.username
|
|
65
|
+
this.email = json.email
|
|
66
|
+
this.validKey = true
|
|
67
|
+
this.verified = json.verified
|
|
68
|
+
this.firstVerification = !json.verified
|
|
69
|
+
if (json.logout) {
|
|
70
|
+
this.app.config.user = {is_authenticated: false}
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
.catch(() => {})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render(): void {
|
|
77
|
+
if (!this.verified) {
|
|
78
|
+
if (this.app.settings?.TEST_SERVER) {
|
|
79
|
+
this.formChecks.push(() =>
|
|
80
|
+
!!(document.getElementById("test-check") as HTMLInputElement)?.matches(
|
|
81
|
+
":checked"
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
this.confirmQuestionsTemplates.unshift(testServerQuestionTemplate)
|
|
85
|
+
}
|
|
86
|
+
this.formChecks.push(() =>
|
|
87
|
+
!!(document.getElementById("terms-check") as HTMLInputElement)?.matches(
|
|
88
|
+
":checked"
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
this.confirmQuestionsTemplates.unshift(checkTermsTemplate)
|
|
92
|
+
}
|
|
93
|
+
this.contents = confirmAccountTemplate({
|
|
94
|
+
validKey: this.validKey,
|
|
95
|
+
username: this.username,
|
|
96
|
+
verified: this.verified,
|
|
97
|
+
email: this.email,
|
|
98
|
+
confirmQuestionsTemplates: this.confirmQuestionsTemplates
|
|
99
|
+
})
|
|
100
|
+
super.render()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
bind(): void {
|
|
104
|
+
super.bind()
|
|
105
|
+
if (!this.formChecks.length) {
|
|
106
|
+
const submitBtn = document.getElementById("submit")
|
|
107
|
+
if (submitBtn) submitBtn.removeAttribute("disabled")
|
|
108
|
+
this.submissionReady = true
|
|
109
|
+
}
|
|
110
|
+
document.querySelectorAll(".checker").forEach(el =>
|
|
111
|
+
el.addEventListener("click", () => {
|
|
112
|
+
if (this.formChecks.every(check => check())) {
|
|
113
|
+
const submitBtn = document.getElementById("submit")
|
|
114
|
+
if (submitBtn) submitBtn.removeAttribute("disabled")
|
|
115
|
+
this.submissionReady = true
|
|
116
|
+
} else {
|
|
117
|
+
const submitBtn = document.getElementById("submit")
|
|
118
|
+
if (submitBtn) submitBtn.setAttribute("disabled", "disabled")
|
|
119
|
+
this.submissionReady = false
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
const submissionButton = document.getElementById("submit")
|
|
124
|
+
if (submissionButton) {
|
|
125
|
+
submissionButton.addEventListener("click", () => {
|
|
126
|
+
if (!this.submissionReady) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
activateWait()
|
|
130
|
+
Promise.all(this.confirmMethods.map(method => method())).then(() => {
|
|
131
|
+
deactivateWait()
|
|
132
|
+
if ((this.app.config as any).user.is_authenticated) {
|
|
133
|
+
const emailObject = (this.app.config as any).user.emails.find(
|
|
134
|
+
(email: any) => email.address === this.email
|
|
135
|
+
)
|
|
136
|
+
if (emailObject) {
|
|
137
|
+
emailObject.verified = true
|
|
138
|
+
}
|
|
139
|
+
return (this.app.goTo("/user/profile/") as any)
|
|
140
|
+
.then(() =>
|
|
141
|
+
addAlert("info", gettext("Email verified!"))
|
|
142
|
+
)
|
|
143
|
+
} else {
|
|
144
|
+
const contentsDOM = document.querySelector(".fw-contents")
|
|
145
|
+
if (contentsDOM) {
|
|
146
|
+
contentsDOM.innerHTML = verifiedAccountTemplate()
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** A template for the confirm email/agree to terms page */
|
|
2
|
+
export const confirmAccountTemplate = ({
|
|
3
|
+
username,
|
|
4
|
+
email,
|
|
5
|
+
verified,
|
|
6
|
+
validKey,
|
|
7
|
+
confirmQuestionsTemplates
|
|
8
|
+
}: {
|
|
9
|
+
username: string
|
|
10
|
+
email: string
|
|
11
|
+
verified: boolean
|
|
12
|
+
validKey: boolean
|
|
13
|
+
confirmQuestionsTemplates: Array<() => string>
|
|
14
|
+
}): string =>
|
|
15
|
+
`<h1 class="fw-login-title">${verified ? gettext("Confirm E-mail Address") : gettext("Confirm E-mail Address and Agree to Terms and Conditions")}</h1>
|
|
16
|
+
${validKey ? confirmAccountFormTemplate({username, email, verified, confirmQuestionsTemplates}) : expiredConfirmationLinkTemplate()}
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
const confirmAccountFormTemplate = ({
|
|
20
|
+
username,
|
|
21
|
+
email,
|
|
22
|
+
verified,
|
|
23
|
+
confirmQuestionsTemplates
|
|
24
|
+
}: {
|
|
25
|
+
username: string
|
|
26
|
+
email: string
|
|
27
|
+
verified: boolean
|
|
28
|
+
confirmQuestionsTemplates: Array<() => string>
|
|
29
|
+
}): string =>
|
|
30
|
+
`<p>${
|
|
31
|
+
verified
|
|
32
|
+
? interpolate(
|
|
33
|
+
gettext(
|
|
34
|
+
'Please confirm that you own the email <a href="mailto:%(email)s">%(email)s</a>.'
|
|
35
|
+
),
|
|
36
|
+
{email},
|
|
37
|
+
true
|
|
38
|
+
)
|
|
39
|
+
: interpolate(
|
|
40
|
+
gettext(
|
|
41
|
+
'Please confirm that you own the email <a href="mailto:%(email)s">%(email)s</a>, that you apply for the username %(username)s, and that you have read and agree to our <a href="/pages/terms/" target="_blank">Terms and Conditions</a> and <a href="/pages/privacy/" target="_blank">Privacy Policy</a>.'
|
|
42
|
+
),
|
|
43
|
+
{email, username},
|
|
44
|
+
true
|
|
45
|
+
)
|
|
46
|
+
}</p>
|
|
47
|
+
<table>
|
|
48
|
+
${confirmQuestionsTemplates.map(template => `<tr>${template()}</tr>`).join("")}
|
|
49
|
+
</table>
|
|
50
|
+
<p class="submit-wrapper">
|
|
51
|
+
<button type="submit" id="submit" disabled class="fw-button fw-orange fw-uppercase">${gettext("Confirm")}</button>
|
|
52
|
+
</p>
|
|
53
|
+
`
|
|
54
|
+
|
|
55
|
+
export const checkTermsTemplate = (): string =>
|
|
56
|
+
`<td>
|
|
57
|
+
<input type="checkbox" class="checker" id="terms-check">
|
|
58
|
+
</td><td>
|
|
59
|
+
${gettext('I have read and agree to the <a href="/pages/terms/" target="_blank">Terms and Conditions</a>.')}
|
|
60
|
+
</td>`
|
|
61
|
+
|
|
62
|
+
export const testServerQuestionTemplate = (): string =>
|
|
63
|
+
`<td>
|
|
64
|
+
<input type="checkbox" class="checker" id="test-check">
|
|
65
|
+
</td><td>
|
|
66
|
+
${gettext("I am aware that I am signing up for a test account and that service may be ended abruptly and without notice, leaving me without my files.")}
|
|
67
|
+
</td>`
|
|
68
|
+
|
|
69
|
+
const expiredConfirmationLinkTemplate = (): string =>
|
|
70
|
+
`<p>
|
|
71
|
+
${gettext("This e-mail confirmation link expired or is invalid. Please try to open another account.")}
|
|
72
|
+
</p>`
|
|
73
|
+
|
|
74
|
+
export const verifiedAccountTemplate = (): string =>
|
|
75
|
+
`<h1>${gettext("Thanks for verifying!")}</h1>
|
|
76
|
+
<p>${gettext("You can now log in.")}</p>`
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {escapeText, postJson} from "fwtoolkit"
|
|
2
|
+
import {PreloginPage} from "../../prelogin/index.js"
|
|
3
|
+
|
|
4
|
+
export class LoginPage extends PreloginPage {
|
|
5
|
+
socialaccount_providers: Array<Record<string, unknown>>
|
|
6
|
+
|
|
7
|
+
constructor({
|
|
8
|
+
app,
|
|
9
|
+
language,
|
|
10
|
+
socialaccount_providers
|
|
11
|
+
}: {
|
|
12
|
+
app: any
|
|
13
|
+
language: string
|
|
14
|
+
socialaccount_providers: Array<Record<string, unknown>>
|
|
15
|
+
}) {
|
|
16
|
+
super({app, language})
|
|
17
|
+
this.socialaccount_providers = socialaccount_providers
|
|
18
|
+
this.title = gettext("Login")
|
|
19
|
+
this.pluginLoaders = []
|
|
20
|
+
this.headerLinks = (
|
|
21
|
+
this.app.settings?.REGISTRATION_OPEN &&
|
|
22
|
+
this.app.settings?.PASSWORD_LOGIN
|
|
23
|
+
? [
|
|
24
|
+
{type: "label", text: gettext("New here?"), link: ""},
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
text: gettext("Sign up"),
|
|
28
|
+
link: "/account/sign-up/"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
: []) as any
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render(): void {
|
|
35
|
+
this.contents = `<div class="fw-login-left">
|
|
36
|
+
<h1 class="fw-login-title">${gettext("Log in")}</h1>
|
|
37
|
+
${
|
|
38
|
+
this.app.settings?.SOCIALACCOUNT_OPEN
|
|
39
|
+
? this.socialaccount_providers.length
|
|
40
|
+
? `<div class="socialaccount_ballot">
|
|
41
|
+
<ul class="socialaccount_providers">
|
|
42
|
+
${this.socialaccount_providers
|
|
43
|
+
.map(
|
|
44
|
+
(provider: any) => `<li>
|
|
45
|
+
<a title="${provider.name}" class="fw-button fw-socialaccount fw-${provider.id}"
|
|
46
|
+
href="${provider.login_url}">
|
|
47
|
+
<span class="fab fa-${provider.id}"></span>
|
|
48
|
+
${gettext("Login with")} ${provider.name}
|
|
49
|
+
</a>
|
|
50
|
+
</li>`
|
|
51
|
+
)
|
|
52
|
+
.join("")}
|
|
53
|
+
</ul>
|
|
54
|
+
</div>`
|
|
55
|
+
: ""
|
|
56
|
+
: ""
|
|
57
|
+
}
|
|
58
|
+
</div>
|
|
59
|
+
${
|
|
60
|
+
this.app.settings?.PASSWORD_LOGIN
|
|
61
|
+
? `<div class="fw-login-right">
|
|
62
|
+
<form>
|
|
63
|
+
<ul id="non-field-errors" class="fw-errorlist"></ul>
|
|
64
|
+
<div class="input-wrapper">
|
|
65
|
+
<label for="id-login">${gettext("Username")}</label>
|
|
66
|
+
<input type="text" name="login" placeholder="${gettext("Username or e-mail")}" autofocus="autofocus" required="" id="id-login" autocomplete="username">
|
|
67
|
+
<ul id="id-login-errors" class="fw-errorlist"></ul>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="input-wrapper">
|
|
70
|
+
<label for="id-password">${gettext("Password")}</label>
|
|
71
|
+
<input type="password" name="password" placeholder="${gettext("Password")}" required="" id="id-password" autocomplete="current-password">
|
|
72
|
+
<ul id="id-password-errors" class="fw-errorlist"></ul>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="submit-wrapper">
|
|
75
|
+
<button class="fw-button fw-dark fw-uppercase" type="submit" id="login-submit">${gettext("Log in")}</button>
|
|
76
|
+
<br>
|
|
77
|
+
<input type="checkbox" name="remember" id="id-remember">
|
|
78
|
+
<label for="id-remember">${gettext("Remember me")}</label>
|
|
79
|
+
</div>
|
|
80
|
+
<a id="lost-passwd" href="/account/password-reset/">${gettext("Forgot Password?")}</a>
|
|
81
|
+
</form>
|
|
82
|
+
</div>`
|
|
83
|
+
: ""
|
|
84
|
+
}`
|
|
85
|
+
super.render()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
bind(): void {
|
|
89
|
+
super.bind()
|
|
90
|
+
const socialButtons = document.body.querySelectorAll(".fw-button.fw-socialaccount")
|
|
91
|
+
let btnWidth = 1
|
|
92
|
+
|
|
93
|
+
socialButtons.forEach((button: Element) => {
|
|
94
|
+
const theWidth = (button as HTMLElement).clientWidth
|
|
95
|
+
if (btnWidth < theWidth) {
|
|
96
|
+
btnWidth = theWidth
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
btnWidth += 15
|
|
100
|
+
socialButtons.forEach(button => ((button as HTMLElement).style.width = `${btnWidth}px`))
|
|
101
|
+
|
|
102
|
+
const loginSubmit = document.querySelector("#login-submit")
|
|
103
|
+
if (!loginSubmit) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
loginSubmit.addEventListener("click", (event: Event) => {
|
|
108
|
+
event.preventDefault()
|
|
109
|
+
|
|
110
|
+
const nonFieldErrors = document.querySelector("#non-field-errors")
|
|
111
|
+
const idLogin = document.querySelector("#id-login") as HTMLInputElement
|
|
112
|
+
const idLoginErrors = document.querySelector("#id-login-errors")
|
|
113
|
+
const idPassword = document.querySelector("#id-password") as HTMLInputElement
|
|
114
|
+
const idPasswordErrors = document.querySelector("#id-password-errors")
|
|
115
|
+
const idRemember = document.querySelector("#id-remember") as HTMLInputElement
|
|
116
|
+
const fwContents = document.querySelector(".fw-contents")
|
|
117
|
+
|
|
118
|
+
if (!idLogin || !idLoginErrors || !idPassword || !idPasswordErrors || !idRemember || !fwContents) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
nonFieldErrors!.innerHTML = ""
|
|
123
|
+
idLoginErrors.innerHTML = ""
|
|
124
|
+
idPasswordErrors.innerHTML = ""
|
|
125
|
+
|
|
126
|
+
const login = idLogin.value
|
|
127
|
+
const password = idPassword.value
|
|
128
|
+
const remember = idRemember.checked
|
|
129
|
+
let errors = false
|
|
130
|
+
if (!login.length) {
|
|
131
|
+
idLoginErrors.innerHTML = `<li>${gettext("This field is required.")}</li>`
|
|
132
|
+
errors = true
|
|
133
|
+
}
|
|
134
|
+
if (!password.length) {
|
|
135
|
+
idPasswordErrors.innerHTML = `<li>${gettext("This field is required.")}</li>`
|
|
136
|
+
errors = true
|
|
137
|
+
}
|
|
138
|
+
if (errors) {
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
return postJson("/api/user/login/", {login, password, remember})
|
|
142
|
+
.catch((response: any) => {
|
|
143
|
+
if (!(response instanceof Response) || response.status !== 400) {
|
|
144
|
+
return Promise.reject(response)
|
|
145
|
+
}
|
|
146
|
+
return response.json().then((json: any) => {
|
|
147
|
+
const needCode =
|
|
148
|
+
json.form.fields.twofactor.errors.includes("required")
|
|
149
|
+
if (
|
|
150
|
+
needCode &&
|
|
151
|
+
!json.form.errors.length &&
|
|
152
|
+
!json.form.fields.login.errors.length &&
|
|
153
|
+
!json.form.fields.password.errors.length
|
|
154
|
+
) {
|
|
155
|
+
import("./two_factor.js").then(({twoFactorLoginDialog}) => {
|
|
156
|
+
twoFactorLoginDialog({
|
|
157
|
+
login,
|
|
158
|
+
password,
|
|
159
|
+
remember,
|
|
160
|
+
loginPage: this
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
} else {
|
|
164
|
+
json.form.errors.forEach(
|
|
165
|
+
(error: string) =>
|
|
166
|
+
(nonFieldErrors!.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
167
|
+
)
|
|
168
|
+
json.form.fields.login.errors.forEach(
|
|
169
|
+
(error: string) =>
|
|
170
|
+
(idLoginErrors.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
171
|
+
)
|
|
172
|
+
json.form.fields.password.errors.forEach(
|
|
173
|
+
(error: string) =>
|
|
174
|
+
(idPasswordErrors.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {json, status: response.status}
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
.then((result: any) => {
|
|
182
|
+
if (!result) return
|
|
183
|
+
const {json, status} = result
|
|
184
|
+
if (status === 400) {
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
this.afterLogin(json)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
afterLogin(json: any): void {
|
|
193
|
+
const currentLang = document.documentElement.lang
|
|
194
|
+
if (json.html && json.html.length > 0) {
|
|
195
|
+
const htmlValues = JSON.parse(json.html)
|
|
196
|
+
|
|
197
|
+
if (htmlValues.Location === "/api/account/confirm-email/") {
|
|
198
|
+
const contentsEl = document.querySelector(".fw-contents")
|
|
199
|
+
if (contentsEl) {
|
|
200
|
+
contentsEl.innerHTML = `<div class="fw-login-left">
|
|
201
|
+
<h1 class="fw-login-title">${gettext("Verify Your E-mail Address")}</h1>
|
|
202
|
+
<p>
|
|
203
|
+
${gettext("We have sent an e-mail to your email address for verification. Follow the link provided to finalize the signup process.")}
|
|
204
|
+
<br />
|
|
205
|
+
${gettext("Please contact us if you do not receive it within a few minutes.")}
|
|
206
|
+
</p>
|
|
207
|
+
</div>`
|
|
208
|
+
}
|
|
209
|
+
} else if (
|
|
210
|
+
htmlValues.user?.language &&
|
|
211
|
+
htmlValues.user?.language !== currentLang
|
|
212
|
+
) {
|
|
213
|
+
window.location.reload()
|
|
214
|
+
} else {
|
|
215
|
+
;(this.app as any).init()
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
;(this.app as any).init()
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {escapeText, get, post} from "fwtoolkit"
|
|
2
|
+
import {PreloginPage} from "../../prelogin/index.js"
|
|
3
|
+
|
|
4
|
+
export class PasswordResetChangePassword extends PreloginPage {
|
|
5
|
+
key: string | false
|
|
6
|
+
|
|
7
|
+
constructor({app, language}: {app: any; language: string}, key: string | false = false) {
|
|
8
|
+
super({app, language})
|
|
9
|
+
this.title = gettext("Change Password")
|
|
10
|
+
this.key = key
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render(): void {
|
|
14
|
+
this.contents = `<div class="fw-login-left">
|
|
15
|
+
<h1 class="fw-login-title">${gettext("Change password")}</h1>
|
|
16
|
+
<p>${gettext("You have indicated that you have forgotten your password. Please enter your new password in the form twice.")}</p>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="fw-login-right">
|
|
19
|
+
<form>
|
|
20
|
+
<ul id="non-field-errors" class="fw-errorlist"></ul>
|
|
21
|
+
<div class="input-wrapper">
|
|
22
|
+
<label for="id-password1">${gettext("Create a password")}</label>
|
|
23
|
+
<input type="password" name="password1" placeholder="${gettext("Password")}" required="" id="id-password1" autocomplete="new-password">
|
|
24
|
+
<ul id="id-password1-errors" class="fw-errorlist"></ul>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="input-wrapper">
|
|
27
|
+
<label for="id-password2">${gettext("Confirm your password")}</label>
|
|
28
|
+
<input type="password" name="password2" placeholder="${gettext("Password (again)")}" required="" id="id-password2" autocomplete="new-password">
|
|
29
|
+
<ul id="id-password2-errors" class="fw-errorlist"></ul>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="submit-wrapper">
|
|
32
|
+
<button class="fw-button fw-dark fw-uppercase" id="change-password-submit" type="submit">${gettext("Change My Password")}</button>
|
|
33
|
+
</div>
|
|
34
|
+
</form>
|
|
35
|
+
</div>`
|
|
36
|
+
super.render()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
bind(): void {
|
|
40
|
+
super.bind()
|
|
41
|
+
|
|
42
|
+
window.history.replaceState({}, "", "/account/change-password/")
|
|
43
|
+
|
|
44
|
+
const passwordInput = document.getElementById("id-password1")
|
|
45
|
+
if (passwordInput) {
|
|
46
|
+
passwordInput.focus()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const submitBtn = document.getElementById("change-password-submit")
|
|
50
|
+
if (submitBtn) {
|
|
51
|
+
submitBtn.addEventListener("click", (event: Event) => {
|
|
52
|
+
event.preventDefault()
|
|
53
|
+
const nonFieldErrors = document.querySelector("#non-field-errors")!
|
|
54
|
+
const pwd1Errors = document.querySelector("#id-password1-errors")!
|
|
55
|
+
const pwd2Errors = document.querySelector("#id-password2-errors")!
|
|
56
|
+
nonFieldErrors.innerHTML = ""
|
|
57
|
+
pwd1Errors.innerHTML = ""
|
|
58
|
+
pwd2Errors.innerHTML = ""
|
|
59
|
+
|
|
60
|
+
const password1 = (document.getElementById("id-password1") as HTMLInputElement).value
|
|
61
|
+
const password2 = (document.getElementById("id-password2") as HTMLInputElement).value
|
|
62
|
+
let errors = false
|
|
63
|
+
if (!password1.length) {
|
|
64
|
+
pwd1Errors.innerHTML = `<li>${gettext("This field is required.")}</li>`
|
|
65
|
+
errors = true
|
|
66
|
+
}
|
|
67
|
+
if (!password2.length) {
|
|
68
|
+
pwd2Errors.innerHTML = `<li>${gettext("This field is required.")}</li>`
|
|
69
|
+
errors = true
|
|
70
|
+
}
|
|
71
|
+
if (password1 !== password2) {
|
|
72
|
+
pwd2Errors.innerHTML = `<li>${gettext("You must type the same password each time.")}</li>`
|
|
73
|
+
errors = true
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (errors) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
get(`/api/account/password/reset/key/${this.key}/`)
|
|
80
|
+
.then((response: any) => {
|
|
81
|
+
return post(response.url, {password1, password2})
|
|
82
|
+
})
|
|
83
|
+
.then(() => {
|
|
84
|
+
if (document.body !== this.dom) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
const contentsEl = document.querySelector(".fw-contents")
|
|
88
|
+
if (contentsEl) {
|
|
89
|
+
contentsEl.innerHTML = `<div class="fw-login-left">
|
|
90
|
+
<h1 class="fw-login-title">${gettext("Password reset")}</h1>
|
|
91
|
+
<p>
|
|
92
|
+
${gettext("Your password has been reset and you can now log in with the new password.")}
|
|
93
|
+
</p>
|
|
94
|
+
</div>`
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
.catch((response: any) =>
|
|
98
|
+
response.json().then((json: any) => {
|
|
99
|
+
json.form.errors.forEach(
|
|
100
|
+
(error: string) =>
|
|
101
|
+
(nonFieldErrors.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
102
|
+
)
|
|
103
|
+
if (json.form.fields.password1) {
|
|
104
|
+
json.form.fields.password1.errors.forEach(
|
|
105
|
+
(error: string) =>
|
|
106
|
+
(pwd1Errors.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
if (json.form.fields.password2) {
|
|
110
|
+
json.form.fields.password2.errors.forEach(
|
|
111
|
+
(error: string) =>
|
|
112
|
+
(pwd2Errors.innerHTML += `<li>${escapeText(error)}</li>`)
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|