@geekity/cms 0.42.0 → 0.42.2
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/admin-bar.d.ts +2 -3
- package/dist/admin/admin-bar.d.ts.map +1 -1
- package/dist/admin/admin-bar.js +4 -5
- package/dist/admin/admin-bar.js.map +1 -1
- package/dist/admin/app-activity.d.ts +1 -1
- package/dist/admin/appearance.d.ts +5 -5
- package/dist/admin/appearance.js +5 -5
- package/dist/admin/comments.d.ts +3 -3
- package/dist/admin/comments.js +2 -2
- package/dist/admin/comments.js.map +1 -1
- package/dist/admin/connected-apps.d.ts +1 -1
- package/dist/admin/connected-apps.js +1 -1
- package/dist/admin/credentials.d.ts +3 -3
- package/dist/admin/credentials.js +3 -3
- package/dist/admin/dashboard.js +2 -2
- package/dist/admin/dashboard.js.map +1 -1
- package/dist/admin/documents.d.ts +4 -4
- package/dist/admin/documents.d.ts.map +1 -1
- package/dist/admin/documents.js +150 -144
- package/dist/admin/documents.js.map +1 -1
- package/dist/admin/editor-actions.d.ts +1 -1
- package/dist/admin/editor-actions.js +1 -1
- package/dist/admin/federation.d.ts +11 -11
- package/dist/admin/federation.d.ts.map +1 -1
- package/dist/admin/federation.js +10 -10
- package/dist/admin/flash.d.ts +8 -0
- package/dist/admin/flash.d.ts.map +1 -1
- package/dist/admin/flash.js +11 -0
- package/dist/admin/flash.js.map +1 -1
- package/dist/admin/indieauth-consent.d.ts +1 -1
- package/dist/admin/indieauth-consent.js +1 -1
- package/dist/admin/legacy-migrations.d.ts +20 -19
- package/dist/admin/legacy-migrations.d.ts.map +1 -1
- package/dist/admin/legacy-migrations.js +14 -13
- package/dist/admin/legacy-migrations.js.map +1 -1
- package/dist/admin/media.js +1 -1
- package/dist/admin/menu.d.ts +1 -1
- package/dist/admin/menu.js +4 -4
- package/dist/admin/menu.js.map +1 -1
- package/dist/admin/messages.d.ts +2 -2
- package/dist/admin/messages.js +2 -2
- package/dist/admin/navigation.d.ts +3 -3
- package/dist/admin/navigation.js +3 -3
- package/dist/admin/personal-data.d.ts +1 -1
- package/dist/admin/personal-data.js +1 -1
- package/dist/admin/plugins.d.ts +1 -1
- package/dist/admin/plugins.js +1 -1
- package/dist/admin/preview.js +3 -3
- package/dist/admin/preview.js.map +1 -1
- package/dist/admin/recovery.d.ts +1 -1
- package/dist/admin/recovery.js +1 -1
- package/dist/admin/routes.d.ts +3 -3
- package/dist/admin/routes.js +14 -14
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/settings-discussion.d.ts +3 -3
- package/dist/admin/settings-discussion.js +3 -3
- package/dist/admin/settings-federation.d.ts +2 -2
- package/dist/admin/settings-federation.js +5 -5
- package/dist/admin/settings-federation.js.map +1 -1
- package/dist/admin/settings-general.d.ts +1 -1
- package/dist/admin/settings-general.js +2 -2
- package/dist/admin/settings-general.js.map +1 -1
- package/dist/admin/settings-page.d.ts +2 -2
- package/dist/admin/settings-page.js +1 -1
- package/dist/admin/settings-pages.d.ts +1 -1
- package/dist/admin/settings-pages.js +1 -1
- package/dist/admin/settings-reading.d.ts +2 -2
- package/dist/admin/settings-reading.js +2 -2
- package/dist/admin/syndication-targets.d.ts +2 -2
- package/dist/admin/syndication-targets.js +2 -2
- package/dist/admin/taxonomy.d.ts +4 -4
- package/dist/admin/taxonomy.js +4 -4
- package/dist/admin/templates.d.ts +2 -2
- package/dist/admin/templates.js +2 -2
- package/dist/admin/tools.d.ts +1 -1
- package/dist/admin/tools.js +1 -1
- package/dist/admin/users.d.ts +0 -159
- package/dist/admin/users.d.ts.map +1 -1
- package/dist/admin/users.js +204 -498
- package/dist/admin/users.js.map +1 -1
- package/dist/avatars/avatars.d.ts +2 -2
- package/dist/avatars/avatars.js +2 -2
- package/dist/cache.d.ts +1 -1
- package/dist/cache.js +1 -1
- package/dist/cli/args.d.ts +20 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +138 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands.d.ts +10 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +261 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/database-in-use.d.ts +9 -0
- package/dist/cli/database-in-use.d.ts.map +1 -0
- package/dist/cli/database-in-use.js +38 -0
- package/dist/cli/database-in-use.js.map +1 -0
- package/dist/cli/dev-mode.d.ts +3 -0
- package/dist/cli/dev-mode.d.ts.map +1 -0
- package/dist/cli/dev-mode.js +31 -0
- package/dist/cli/dev-mode.js.map +1 -0
- package/dist/cli/export.d.ts +3 -0
- package/dist/cli/export.d.ts.map +1 -0
- package/dist/cli/export.js +53 -0
- package/dist/cli/export.js.map +1 -0
- package/dist/cli/format.d.ts +3 -0
- package/dist/cli/format.d.ts.map +1 -0
- package/dist/cli/format.js +10 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/gemini.d.ts +3 -0
- package/dist/cli/gemini.d.ts.map +1 -0
- package/dist/cli/gemini.js +34 -0
- package/dist/cli/gemini.js.map +1 -0
- package/dist/cli/help.d.ts +2 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +111 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/import.d.ts +3 -0
- package/dist/cli/import.d.ts.map +1 -0
- package/dist/cli/import.js +84 -0
- package/dist/cli/import.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +21 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/maintenance.d.ts +3 -0
- package/dist/cli/maintenance.d.ts.map +1 -0
- package/dist/cli/maintenance.js +57 -0
- package/dist/cli/maintenance.js.map +1 -0
- package/dist/cli/options.d.ts +16 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +27 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/cli/password.d.ts +21 -0
- package/dist/cli/password.d.ts.map +1 -0
- package/dist/cli/password.js +52 -0
- package/dist/cli/password.js.map +1 -0
- package/dist/cli/plugin-commands.d.ts +11 -0
- package/dist/cli/plugin-commands.d.ts.map +1 -0
- package/dist/cli/plugin-commands.js +79 -0
- package/dist/cli/plugin-commands.js.map +1 -0
- package/dist/cli/plugin-folder.d.ts +3 -0
- package/dist/cli/plugin-folder.d.ts.map +1 -0
- package/dist/cli/plugin-folder.js +93 -0
- package/dist/cli/plugin-folder.js.map +1 -0
- package/dist/cli/rebuild.d.ts +5 -0
- package/dist/cli/rebuild.d.ts.map +1 -0
- package/dist/cli/rebuild.js +44 -0
- package/dist/cli/rebuild.js.map +1 -0
- package/dist/cli/resend.d.ts +3 -0
- package/dist/cli/resend.d.ts.map +1 -0
- package/dist/cli/resend.js +36 -0
- package/dist/cli/resend.js.map +1 -0
- package/dist/cli/run-job.d.ts +5 -0
- package/dist/cli/run-job.d.ts.map +1 -0
- package/dist/cli/run-job.js +29 -0
- package/dist/cli/run-job.js.map +1 -0
- package/dist/cli/serve.d.ts +3 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +65 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/settings.d.ts +5 -0
- package/dist/cli/settings.d.ts.map +1 -0
- package/dist/cli/settings.js +144 -0
- package/dist/cli/settings.js.map +1 -0
- package/dist/cli/site-plugins.d.ts +5 -0
- package/dist/cli/site-plugins.d.ts.map +1 -0
- package/dist/cli/site-plugins.js +7 -0
- package/dist/cli/site-plugins.js.map +1 -0
- package/dist/cli/strip-metadata.d.ts +3 -0
- package/dist/cli/strip-metadata.d.ts.map +1 -0
- package/dist/cli/strip-metadata.js +20 -0
- package/dist/cli/strip-metadata.js.map +1 -0
- package/dist/cli/sync.d.ts +3 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +22 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/user.d.ts +3 -0
- package/dist/cli/user.d.ts.map +1 -0
- package/dist/cli/user.js +54 -0
- package/dist/cli/user.js.map +1 -0
- package/dist/cli.d.ts +0 -62
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -1566
- package/dist/cli.js.map +1 -1
- package/dist/cms/app.js +10 -10
- package/dist/cms/app.js.map +1 -1
- package/dist/cms/boot.js +5 -5
- package/dist/cms/boot.js.map +1 -1
- package/dist/cms/create.d.ts +17 -17
- package/dist/cms/create.d.ts.map +1 -1
- package/dist/cms/create.js +1 -1
- package/dist/cms/create.js.map +1 -1
- package/dist/cms/server-error.d.ts +1 -1
- package/dist/cms/server-error.js +1 -1
- package/dist/cms/services.js +14 -14
- package/dist/cms/services.js.map +1 -1
- package/dist/comments/akismet.d.ts +4 -4
- package/dist/comments/akismet.js +6 -6
- package/dist/comments/akismet.js.map +1 -1
- package/dist/comments/conversation.d.ts +29 -29
- package/dist/comments/conversation.d.ts.map +1 -1
- package/dist/comments/conversation.js +2 -2
- package/dist/comments/conversation.js.map +1 -1
- package/dist/comments/form.d.ts +3 -3
- package/dist/comments/form.d.ts.map +1 -1
- package/dist/comments/intake.d.ts +4 -4
- package/dist/comments/intake.d.ts.map +1 -1
- package/dist/comments/intake.js +1 -1
- package/dist/comments/migrations.d.ts +3 -3
- package/dist/comments/migrations.js +3 -3
- package/dist/comments/moderate.d.ts +2 -2
- package/dist/comments/moderate.js +2 -2
- package/dist/comments/page-form.d.ts +1 -1
- package/dist/comments/page-form.js +1 -1
- package/dist/comments/records.d.ts +9 -9
- package/dist/comments/records.d.ts.map +1 -1
- package/dist/comments/records.js +11 -10
- package/dist/comments/records.js.map +1 -1
- package/dist/comments/reply-notices.d.ts +2 -2
- package/dist/comments/reply-post.d.ts +2 -2
- package/dist/comments/submission.d.ts +8 -8
- package/dist/comments/submission.d.ts.map +1 -1
- package/dist/comments/submission.js +9 -9
- package/dist/comments/submission.js.map +1 -1
- package/dist/config.d.ts +27 -27
- package/dist/config.js +3 -3
- package/dist/contact/index.d.ts +1 -1
- package/dist/contact/index.js +1 -1
- package/dist/contact/records.d.ts +7 -7
- package/dist/contact/records.js +7 -7
- package/dist/content/alt-text.d.ts +2 -2
- package/dist/content/alt-text.js +2 -2
- package/dist/content/authors.d.ts +6 -6
- package/dist/content/authors.d.ts.map +1 -1
- package/dist/content/authors.js +6 -6
- package/dist/content/authors.js.map +1 -1
- package/dist/content/citation.d.ts +1 -1
- package/dist/content/content-tree.d.ts +5 -0
- package/dist/content/content-tree.d.ts.map +1 -0
- package/dist/content/content-tree.js +54 -0
- package/dist/content/content-tree.js.map +1 -0
- package/dist/content/content-watcher.d.ts +15 -0
- package/dist/content/content-watcher.d.ts.map +1 -0
- package/dist/content/content-watcher.js +104 -0
- package/dist/content/content-watcher.js.map +1 -0
- package/dist/content/document-form.d.ts +25 -24
- package/dist/content/document-form.d.ts.map +1 -1
- package/dist/content/document-form.js +7 -7
- package/dist/content/document-form.js.map +1 -1
- package/dist/content/document-kind.d.ts +6 -6
- package/dist/content/document.d.ts +1 -1
- package/dist/content/enclosure-form.js +1 -1
- package/dist/content/enclosure.js +1 -1
- package/dist/content/event-form.d.ts +2 -2
- package/dist/content/event.d.ts +3 -3
- package/dist/content/event.js +3 -3
- package/dist/content/guids.d.ts +6 -6
- package/dist/content/guids.d.ts.map +1 -1
- package/dist/content/guids.js +7 -7
- package/dist/content/guids.js.map +1 -1
- package/dist/content/handles.d.ts +1 -1
- package/dist/content/handles.js +1 -1
- package/dist/content/html-to-markdown.js +2 -2
- package/dist/content/language.d.ts +1 -1
- package/dist/content/language.js +1 -1
- package/dist/content/locale.d.ts +1 -1
- package/dist/content/locale.js +1 -1
- package/dist/content/markdown.d.ts +1 -1
- package/dist/content/markdown.js +1 -1
- package/dist/content/parser.d.ts +1 -1
- package/dist/content/parser.d.ts.map +1 -1
- package/dist/content/permalinks.d.ts +4 -4
- package/dist/content/permalinks.js +4 -4
- package/dist/content/photo-form.js +2 -2
- package/dist/content/photo.d.ts +2 -2
- package/dist/content/photo.js +1 -1
- package/dist/content/pinned.d.ts +3 -3
- package/dist/content/pinned.js +3 -3
- package/dist/content/post-fields.js +2 -2
- package/dist/content/post-fields.js.map +1 -1
- package/dist/content/post-type.d.ts +4 -4
- package/dist/content/post-type.js +1 -1
- package/dist/content/reconcile.d.ts +15 -0
- package/dist/content/reconcile.d.ts.map +1 -0
- package/dist/content/reconcile.js +106 -0
- package/dist/content/reconcile.js.map +1 -0
- package/dist/content/redirects.d.ts +2 -3
- package/dist/content/redirects.d.ts.map +1 -1
- package/dist/content/redirects.js +2 -3
- package/dist/content/redirects.js.map +1 -1
- package/dist/content/rsvp.d.ts +1 -1
- package/dist/content/rsvp.js +1 -1
- package/dist/content/sanitize.js +1 -1
- package/dist/content/save.d.ts +3 -3
- package/dist/content/save.js +4 -4
- package/dist/content/scan.d.ts +12 -0
- package/dist/content/scan.d.ts.map +1 -0
- package/dist/content/scan.js +58 -0
- package/dist/content/scan.js.map +1 -0
- package/dist/content/search.d.ts +3 -3
- package/dist/content/search.js +3 -3
- package/dist/content/served.d.ts +5 -5
- package/dist/content/served.js +4 -4
- package/dist/content/site-links.d.ts +3 -4
- package/dist/content/site-links.d.ts.map +1 -1
- package/dist/content/site-links.js +1 -2
- package/dist/content/site-links.js.map +1 -1
- package/dist/content/sqlite/clauses.d.ts +1 -1
- package/dist/content/sqlite/clauses.js +1 -1
- package/dist/content/sqlite/rows.d.ts +1 -1
- package/dist/content/sqlite/rows.js +1 -1
- package/dist/content/store.d.ts +26 -26
- package/dist/content/sync.d.ts +3 -3
- package/dist/content/sync.d.ts.map +1 -1
- package/dist/content/sync.js +65 -382
- package/dist/content/sync.js.map +1 -1
- package/dist/content/taxonomy.d.ts +9 -8
- package/dist/content/taxonomy.d.ts.map +1 -1
- package/dist/content/taxonomy.js +9 -8
- package/dist/content/taxonomy.js.map +1 -1
- package/dist/content/time.d.ts +1 -1
- package/dist/content/time.js +1 -1
- package/dist/content/trash.d.ts +4 -5
- package/dist/content/trash.d.ts.map +1 -1
- package/dist/content/trash.js +4 -5
- package/dist/content/trash.js.map +1 -1
- package/dist/content/write.d.ts +4 -4
- package/dist/content/write.js +19 -19
- package/dist/content/write.js.map +1 -1
- package/dist/drain.d.ts +1 -1
- package/dist/drain.js +1 -1
- package/dist/federation/actor.d.ts +9 -9
- package/dist/federation/actor.js +10 -10
- package/dist/federation/article.d.ts +14 -14
- package/dist/federation/article.js +27 -27
- package/dist/federation/article.js.map +1 -1
- package/dist/federation/backfill.d.ts +2 -2
- package/dist/federation/backfill.js +2 -2
- package/dist/federation/citations.d.ts +1 -1
- package/dist/federation/citations.js +1 -1
- package/dist/federation/cited-post.d.ts +1 -1
- package/dist/federation/cited-post.js +1 -1
- package/dist/federation/delivery-plan.d.ts +1 -1
- package/dist/federation/delivery.d.ts +3 -3
- package/dist/federation/delivery.d.ts.map +1 -1
- package/dist/federation/delivery.js +11 -12
- package/dist/federation/delivery.js.map +1 -1
- package/dist/federation/federation.d.ts +3 -3
- package/dist/federation/federation.d.ts.map +1 -1
- package/dist/federation/federation.js +7 -8
- package/dist/federation/federation.js.map +1 -1
- package/dist/federation/handles.d.ts +1 -1
- package/dist/federation/handles.js +1 -1
- package/dist/federation/inbox.d.ts +6 -6
- package/dist/federation/inbox.js +9 -9
- package/dist/federation/keys.d.ts +3 -3
- package/dist/federation/keys.js +3 -3
- package/dist/federation/object-ids.d.ts +1 -1
- package/dist/federation/paths.d.ts +8 -8
- package/dist/federation/paths.js +8 -8
- package/dist/federation/profiles.d.ts +2 -3
- package/dist/federation/profiles.d.ts.map +1 -1
- package/dist/federation/profiles.js +2 -3
- package/dist/federation/profiles.js.map +1 -1
- package/dist/federation/quotes.d.ts +1 -1
- package/dist/federation/records.d.ts +24 -24
- package/dist/federation/records.js +23 -23
- package/dist/federation/records.js.map +1 -1
- package/dist/federation/refusals.d.ts +1 -1
- package/dist/federation/relays.d.ts +1 -1
- package/dist/federation/relays.js +6 -6
- package/dist/federation/webfinger.d.ts +2 -2
- package/dist/federation/webfinger.js +2 -2
- package/dist/files/atomic.d.ts +2 -2
- package/dist/files/atomic.js +1 -1
- package/dist/forms/checker.d.ts +2 -2
- package/dist/forms/checker.d.ts.map +1 -1
- package/dist/forms/protection.d.ts +1 -1
- package/dist/forms/protection.js +1 -1
- package/dist/gemini/certificate.js +1 -1
- package/dist/images/markup.d.ts +2 -2
- package/dist/images/variants.d.ts +8 -8
- package/dist/images/variants.js +1 -1
- package/dist/indexnow.d.ts +1 -1
- package/dist/indieauth/grants.d.ts +2 -2
- package/dist/indieauth/identity.d.ts +3 -5
- package/dist/indieauth/identity.d.ts.map +1 -1
- package/dist/indieauth/identity.js +3 -5
- package/dist/indieauth/identity.js.map +1 -1
- package/dist/indieauth/redeem.d.ts +2 -2
- package/dist/indieauth/redeem.js +2 -2
- package/dist/indieauth/request.d.ts +2 -2
- package/dist/indieauth/request.js +2 -2
- package/dist/indieauth/tokens.d.ts +3 -5
- package/dist/indieauth/tokens.d.ts.map +1 -1
- package/dist/indieauth/tokens.js +3 -5
- package/dist/indieauth/tokens.js.map +1 -1
- package/dist/jobs/file-records.d.ts +1 -1
- package/dist/jobs/file-records.js +1 -1
- package/dist/jobs/in-process.d.ts +1 -1
- package/dist/jobs/in-process.js +1 -1
- package/dist/jobs/queue.d.ts +1 -1
- package/dist/jobs/queue.js +1 -1
- package/dist/mail/provider.d.ts +2 -2
- package/dist/mail/provider.js +2 -2
- package/dist/media/library.d.ts +2 -2
- package/dist/media/uploads.js +2 -2
- package/dist/media/uploads.js.map +1 -1
- package/dist/micropub/create.d.ts +1 -1
- package/dist/micropub/endpoint.d.ts +7 -7
- package/dist/micropub/endpoint.js +8 -8
- package/dist/micropub/endpoint.js.map +1 -1
- package/dist/micropub/media.d.ts +4 -4
- package/dist/micropub/media.js +4 -4
- package/dist/micropub/update.d.ts +1 -1
- package/dist/micropub/update.js +1 -1
- package/dist/notifications/comments.d.ts +1 -1
- package/dist/notifications/comments.js +2 -2
- package/dist/notifications/comments.js.map +1 -1
- package/dist/notifications/digest.d.ts +7 -7
- package/dist/notifications/digest.js +7 -7
- package/dist/notifications/mail-service.d.ts +4 -4
- package/dist/notifications/mail-service.d.ts.map +1 -1
- package/dist/notifications/mail-service.js +3 -3
- package/dist/notifications/mail-templates.d.ts +3 -3
- package/dist/notifications/optouts.d.ts +1 -1
- package/dist/notifications/optouts.js +1 -1
- package/dist/notifications/tokens.d.ts +2 -2
- package/dist/plugin.d.ts +5 -5
- package/dist/plugin.js +5 -5
- package/dist/plugins/changes.js +2 -2
- package/dist/plugins/folder.d.ts +2 -2
- package/dist/plugins/folder.js +2 -2
- package/dist/plugins/install.d.ts +1 -1
- package/dist/plugins/install.js +1 -1
- package/dist/plugins/registry.d.ts +1 -1
- package/dist/plugins/registry.js +1 -1
- package/dist/plugins/site.d.ts +1 -1
- package/dist/plugins/site.js +1 -1
- package/dist/privacy/erase.d.ts +1 -1
- package/dist/privacy/erase.js +1 -1
- package/dist/privacy/retention.d.ts +2 -2
- package/dist/privacy/retention.js +2 -2
- package/dist/site/admin-paths.d.ts +2 -2
- package/dist/site/admin-paths.js +2 -2
- package/dist/site/authors.d.ts +6 -6
- package/dist/site/authors.js +5 -5
- package/dist/site/dashboard-layout.d.ts +1 -1
- package/dist/site/indexnow-key.js +1 -1
- package/dist/site/namespace.d.ts +1 -1
- package/dist/site/namespace.js +1 -1
- package/dist/site/navigation.d.ts +10 -10
- package/dist/site/navigation.js +10 -10
- package/dist/site/notification-preferences.d.ts +3 -3
- package/dist/site/notification-preferences.js +2 -2
- package/dist/site/retention-policy.d.ts +1 -1
- package/dist/site/retention-policy.js +1 -1
- package/dist/site/users.d.ts +23 -24
- package/dist/site/users.d.ts.map +1 -1
- package/dist/site/users.js +6 -6
- package/dist/site/users.js.map +1 -1
- package/dist/store/admin-store.d.ts +2 -2
- package/dist/store/comments.d.ts +17 -17
- package/dist/store/comments.d.ts.map +1 -1
- package/dist/store/comments.js +14 -21
- package/dist/store/comments.js.map +1 -1
- package/dist/store/conversation.d.ts +2 -2
- package/dist/store/deliveries.d.ts +1 -1
- package/dist/store/deliveries.d.ts.map +1 -1
- package/dist/store/deliveries.js +10 -15
- package/dist/store/deliveries.js.map +1 -1
- package/dist/store/followers.d.ts +5 -5
- package/dist/store/followers.d.ts.map +1 -1
- package/dist/store/followers.js +7 -10
- package/dist/store/followers.js.map +1 -1
- package/dist/store/inbox-replies.d.ts +4 -4
- package/dist/store/inbox-replies.js +4 -4
- package/dist/store/inbox.d.ts +5 -5
- package/dist/store/inbox.d.ts.map +1 -1
- package/dist/store/inbox.js +21 -34
- package/dist/store/inbox.js.map +1 -1
- package/dist/store/profiles.d.ts +5 -5
- package/dist/store/profiles.d.ts.map +1 -1
- package/dist/store/profiles.js +4 -5
- package/dist/store/profiles.js.map +1 -1
- package/dist/store/relays.d.ts.map +1 -1
- package/dist/store/relays.js +7 -9
- package/dist/store/relays.js.map +1 -1
- package/dist/store/rows.d.ts +6 -20
- package/dist/store/rows.d.ts.map +1 -1
- package/dist/store/rows.js +10 -15
- package/dist/store/rows.js.map +1 -1
- package/dist/store/schema.js +35 -35
- package/dist/store/schema.js.map +1 -1
- package/dist/store/sessions.d.ts +1 -1
- package/dist/store/sessions.d.ts.map +1 -1
- package/dist/store/sessions.js +10 -10
- package/dist/store/sessions.js.map +1 -1
- package/dist/store/state.d.ts.map +1 -1
- package/dist/store/state.js +2 -2
- package/dist/store/state.js.map +1 -1
- package/dist/store/tokens.d.ts +1 -1
- package/dist/store/tokens.d.ts.map +1 -1
- package/dist/store/tokens.js +5 -5
- package/dist/store/tokens.js.map +1 -1
- package/dist/store/webmentions.d.ts +2 -2
- package/dist/store/webmentions.d.ts.map +1 -1
- package/dist/store/webmentions.js +11 -11
- package/dist/store/webmentions.js.map +1 -1
- package/dist/supervisor/plugin-watcher.d.ts +26 -0
- package/dist/supervisor/plugin-watcher.d.ts.map +1 -0
- package/dist/supervisor/plugin-watcher.js +90 -0
- package/dist/supervisor/plugin-watcher.js.map +1 -0
- package/dist/supervisor/primary.d.ts +4 -7
- package/dist/supervisor/primary.d.ts.map +1 -1
- package/dist/supervisor/primary.js +37 -94
- package/dist/supervisor/primary.js.map +1 -1
- package/dist/supervisor/protocol.d.ts +1 -1
- package/dist/supervisor/protocol.js +1 -1
- package/dist/supervisor/reload-queue.d.ts +10 -0
- package/dist/supervisor/reload-queue.d.ts.map +1 -0
- package/dist/supervisor/reload-queue.js +28 -0
- package/dist/supervisor/reload-queue.js.map +1 -0
- package/dist/supervisor/supervision.d.ts +2 -2
- package/dist/supervisor/supervision.js +2 -2
- package/dist/supervisor/worker.d.ts +1 -1
- package/dist/supervisor/worker.js +1 -1
- package/dist/theme/site-data.d.ts +3 -3
- package/dist/theme/site-data.js +2 -2
- package/dist/theme/templates.d.ts +3 -3
- package/dist/theme/templates.js +16 -16
- package/dist/theme/templates.js.map +1 -1
- package/dist/theme/themes.d.ts +11 -13
- package/dist/theme/themes.d.ts.map +1 -1
- package/dist/theme/themes.js +8 -9
- package/dist/theme/themes.js.map +1 -1
- package/dist/web/activity-folding.d.ts +33 -0
- package/dist/web/activity-folding.d.ts.map +1 -0
- package/dist/web/activity-folding.js +238 -0
- package/dist/web/activity-folding.js.map +1 -0
- package/dist/web/archive.d.ts +2 -3
- package/dist/web/archive.d.ts.map +1 -1
- package/dist/web/archive.js +2 -3
- package/dist/web/archive.js.map +1 -1
- package/dist/web/asset-routes.d.ts +1 -1
- package/dist/web/asset-routes.js +1 -1
- package/dist/web/comment-routes.js +2 -2
- package/dist/web/comment-routes.js.map +1 -1
- package/dist/web/compression.d.ts +1 -1
- package/dist/web/compression.js +1 -1
- package/dist/web/context.d.ts +21 -21
- package/dist/web/context.d.ts.map +1 -1
- package/dist/web/context.js +7 -7
- package/dist/web/conversation-context.d.ts +15 -0
- package/dist/web/conversation-context.d.ts.map +1 -0
- package/dist/web/conversation-context.js +2 -0
- package/dist/web/conversation-context.js.map +1 -0
- package/dist/web/conversation-feed.d.ts +18 -0
- package/dist/web/conversation-feed.d.ts.map +1 -0
- package/dist/web/conversation-feed.js +53 -0
- package/dist/web/conversation-feed.js.map +1 -0
- package/dist/web/conversation-gather.d.ts +12 -0
- package/dist/web/conversation-gather.d.ts.map +1 -0
- package/dist/web/conversation-gather.js +189 -0
- package/dist/web/conversation-gather.js.map +1 -0
- package/dist/web/conversation-lookup.d.ts +15 -0
- package/dist/web/conversation-lookup.d.ts.map +1 -0
- package/dist/web/conversation-lookup.js +101 -0
- package/dist/web/conversation-lookup.js.map +1 -0
- package/dist/web/conversation-threads.d.ts +12 -0
- package/dist/web/conversation-threads.d.ts.map +1 -0
- package/dist/web/conversation-threads.js +144 -0
- package/dist/web/conversation-threads.js.map +1 -0
- package/dist/web/conversation.d.ts +25 -61
- package/dist/web/conversation.d.ts.map +1 -1
- package/dist/web/conversation.js +14 -854
- package/dist/web/conversation.js.map +1 -1
- package/dist/web/document-page.js +4 -4
- package/dist/web/document-page.js.map +1 -1
- package/dist/web/document-render.d.ts +9 -0
- package/dist/web/document-render.d.ts.map +1 -0
- package/dist/web/document-render.js +130 -0
- package/dist/web/document-render.js.map +1 -0
- package/dist/web/document-site.d.ts +1 -1
- package/dist/web/document-site.d.ts.map +1 -1
- package/dist/web/document-site.js +1 -1
- package/dist/web/document-site.js.map +1 -1
- package/dist/web/env.d.ts +19 -19
- package/dist/web/env.d.ts.map +1 -1
- package/dist/web/federation-routes.d.ts +2 -2
- package/dist/web/federation-routes.d.ts.map +1 -1
- package/dist/web/federation-routes.js +22 -21
- package/dist/web/federation-routes.js.map +1 -1
- package/dist/web/feed-atom.d.ts +3 -3
- package/dist/web/feed-atom.js +3 -3
- package/dist/web/feed-item.d.ts +15 -16
- package/dist/web/feed-item.d.ts.map +1 -1
- package/dist/web/feed-item.js +1 -1
- package/dist/web/feed-item.js.map +1 -1
- package/dist/web/feed-json.d.ts +4 -4
- package/dist/web/feed-json.d.ts.map +1 -1
- package/dist/web/feed-json.js +2 -2
- package/dist/web/feed-routes.d.ts +3 -3
- package/dist/web/feed-routes.js +4 -4
- package/dist/web/feed-routes.js.map +1 -1
- package/dist/web/feed-rss.d.ts +2 -2
- package/dist/web/feed-rss.js +4 -4
- package/dist/web/feed-rss.js.map +1 -1
- package/dist/web/feed-source.d.ts +5 -5
- package/dist/web/feed-source.d.ts.map +1 -1
- package/dist/web/feed-source.js +2 -2
- package/dist/web/feed-source.js.map +1 -1
- package/dist/web/feed-xml.d.ts +4 -4
- package/dist/web/feed-xml.d.ts.map +1 -1
- package/dist/web/feed-xml.js +4 -4
- package/dist/web/feed-xml.js.map +1 -1
- package/dist/web/font-routes.d.ts +1 -1
- package/dist/web/font-routes.js +1 -1
- package/dist/web/health.d.ts +1 -1
- package/dist/web/index.d.ts +5 -3
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +4 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/indieauth-activity-log.js +1 -1
- package/dist/web/indieauth-bearer.d.ts +2 -2
- package/dist/web/indieauth-discovery.d.ts +12 -12
- package/dist/web/indieauth-discovery.d.ts.map +1 -1
- package/dist/web/indieauth-discovery.js +12 -12
- package/dist/web/indieauth-discovery.js.map +1 -1
- package/dist/web/indieauth-token.d.ts +2 -2
- package/dist/web/indieauth-token.js +2 -2
- package/dist/web/listing-render.d.ts +11 -0
- package/dist/web/listing-render.d.ts.map +1 -0
- package/dist/web/listing-render.js +76 -0
- package/dist/web/listing-render.js.map +1 -0
- package/dist/web/listing-subject.js +1 -1
- package/dist/web/listing-subject.js.map +1 -1
- package/dist/web/llms.d.ts +1 -1
- package/dist/web/llms.js +1 -1
- package/dist/web/maintenance.d.ts +1 -1
- package/dist/web/maintenance.js +1 -1
- package/dist/web/manifest.d.ts +1 -1
- package/dist/web/manifest.js +1 -1
- package/dist/web/markdown-chrome.d.ts +11 -0
- package/dist/web/markdown-chrome.d.ts.map +1 -0
- package/dist/web/markdown-chrome.js +178 -0
- package/dist/web/markdown-chrome.js.map +1 -0
- package/dist/web/markdown-conversation.d.ts +1 -1
- package/dist/web/markdown-conversation.d.ts.map +1 -1
- package/dist/web/markdown-environment.d.ts +10 -0
- package/dist/web/markdown-environment.d.ts.map +1 -0
- package/dist/web/markdown-environment.js +56 -0
- package/dist/web/markdown-environment.js.map +1 -0
- package/dist/web/markdown-representation.d.ts +1 -1
- package/dist/web/markdown-representation.d.ts.map +1 -1
- package/dist/web/markdown-representation.js +2 -2
- package/dist/web/markdown-representation.js.map +1 -1
- package/dist/web/negotiate.d.ts +9 -6
- package/dist/web/negotiate.d.ts.map +1 -1
- package/dist/web/negotiate.js +17 -13
- package/dist/web/negotiate.js.map +1 -1
- package/dist/web/oembed.d.ts +3 -3
- package/dist/web/oembed.js +3 -3
- package/dist/web/opensearch.d.ts +1 -1
- package/dist/web/opensearch.js +1 -1
- package/dist/web/page-context.d.ts +29 -0
- package/dist/web/page-context.d.ts.map +1 -0
- package/dist/web/page-context.js +126 -0
- package/dist/web/page-context.js.map +1 -0
- package/dist/web/page-tags.js +1 -1
- package/dist/web/page-tags.js.map +1 -1
- package/dist/web/paths.d.ts +1 -1
- package/dist/web/paths.js +3 -3
- package/dist/web/plugin-federation.d.ts +1 -1
- package/dist/web/plugin-federation.js +1 -1
- package/dist/web/render-scope.d.ts +20 -0
- package/dist/web/render-scope.d.ts.map +1 -0
- package/dist/web/render-scope.js +36 -0
- package/dist/web/render-scope.js.map +1 -0
- package/dist/web/render.d.ts +21 -363
- package/dist/web/render.d.ts.map +1 -1
- package/dist/web/render.js +46 -899
- package/dist/web/render.js.map +1 -1
- package/dist/web/request.d.ts +1 -1
- package/dist/web/request.js +1 -1
- package/dist/web/robots.d.ts +1 -1
- package/dist/web/robots.js +1 -1
- package/dist/web/routes.js +19 -19
- package/dist/web/routes.js.map +1 -1
- package/dist/web/search.d.ts +1 -1
- package/dist/web/search.js +1 -1
- package/dist/web/session.d.ts +8 -8
- package/dist/web/session.js +8 -8
- package/dist/web/share-image.d.ts +2 -3
- package/dist/web/share-image.d.ts.map +1 -1
- package/dist/web/share-image.js +1 -1
- package/dist/web/share-image.js.map +1 -1
- package/dist/web/site-view.d.ts +2 -2
- package/dist/web/status-pages.d.ts +1 -1
- package/dist/web/status-pages.d.ts.map +1 -1
- package/dist/web/theme-environment.d.ts +14 -0
- package/dist/web/theme-environment.d.ts.map +1 -0
- package/dist/web/theme-environment.js +112 -0
- package/dist/web/theme-environment.js.map +1 -0
- package/dist/web/theme-templates.d.ts +67 -0
- package/dist/web/theme-templates.d.ts.map +1 -0
- package/dist/web/theme-templates.js +65 -0
- package/dist/web/theme-templates.js.map +1 -0
- package/dist/webmention/microformats.d.ts +5 -5
- package/dist/webmention/microformats.d.ts.map +1 -1
- package/dist/webmention/receive.d.ts +7 -7
- package/dist/webmention/receive.d.ts.map +1 -1
- package/dist/webmention/receive.js +4 -4
- package/dist/webmention/receive.js.map +1 -1
- package/dist/webmention/reply-context/oembed.js +1 -1
- package/dist/webmention/reply-context.d.ts +10 -10
- package/dist/webmention/reply-context.d.ts.map +1 -1
- package/dist/webmention/reply-context.js +5 -5
- package/dist/webmention/reply-contexts.d.ts +6 -6
- package/dist/webmention/reply-contexts.d.ts.map +1 -1
- package/dist/webmention/reply-contexts.js +2 -2
- package/dist/webmention/service.d.ts +13 -13
- package/dist/webmention/service.js +9 -9
- package/dist/webmention/syndication.d.ts +6 -6
- package/dist/webmention/syndication.d.ts.map +1 -1
- package/dist/webmention/syndication.js +6 -6
- package/dist/webmention/syndication.js.map +1 -1
- package/package.json +2 -2
package/dist/admin/users.js
CHANGED
|
@@ -9,77 +9,27 @@ import { discardWritingLedger } from '../writing/ledger.js';
|
|
|
9
9
|
import { stringOrEmpty } from '../util/forms.js';
|
|
10
10
|
import { ADMIN_THEMES, adminTheme } from '../site/admin-theme.js';
|
|
11
11
|
import { emailProblem, passwordProblem, usernameProblem } from './credentials.js';
|
|
12
|
-
import {
|
|
12
|
+
import { flashAndRedirect } from './flash.js';
|
|
13
13
|
import { editUserPath, USERS_PATH } from '../site/admin-paths.js';
|
|
14
14
|
import { toldFollowers } from './settings-page.js';
|
|
15
15
|
import { ADMIN_TEMPLATES } from './templates.js';
|
|
16
|
-
/**
|
|
17
|
-
* Where the add form lives, and where it posts.
|
|
18
|
-
*
|
|
19
|
-
* A screen of its own rather than a panel under the table, because the menu
|
|
20
|
-
* says Users > Add new and a menu entry has to be somewhere to go. It is also
|
|
21
|
-
* what keeps a refused add on a page about adding somebody instead of at the
|
|
22
|
-
* top of a list of everybody.
|
|
23
|
-
*/
|
|
24
16
|
export const ADD_USER_PATH = `${USERS_PATH}/new`;
|
|
25
|
-
/**
|
|
26
|
-
* The id in `/admin/users/<id>`, or `undefined` for a segment that is not one.
|
|
27
|
-
*
|
|
28
|
-
* Digits only, so `new`, `password` and the other named paths under
|
|
29
|
-
* `/admin/users/` can never be read as somebody's id — and so a URL somebody
|
|
30
|
-
* typed answers 404 rather than `NaN`.
|
|
31
|
-
*/
|
|
32
17
|
function pathId(segment) {
|
|
33
18
|
if (!/^\d+$/.test(segment))
|
|
34
19
|
return undefined;
|
|
35
20
|
return Number(segment);
|
|
36
21
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Users > Connected apps: the apps holding a token for whoever is signed in
|
|
39
|
-
* (TASK-162). Mounted by `admin/connected-apps.ts`; named here so the
|
|
40
|
-
* menu can link it without importing the IndieAuth side.
|
|
41
|
-
*/
|
|
42
22
|
export const CONNECTED_APPS_PATH = `${USERS_PATH}/apps`;
|
|
43
|
-
/** The child of Users the connected apps screen is. */
|
|
44
23
|
export const CONNECTED_APPS_CHILD = 'apps';
|
|
45
|
-
/**
|
|
46
|
-
* Users > App activity: what apps sent to the IndieAuth and Micropub
|
|
47
|
-
* endpoints, and what they were answered (TASK-221). Mounted by
|
|
48
|
-
* `admin/app-activity.ts`; named here for the same reason as Connected apps.
|
|
49
|
-
*/
|
|
50
24
|
export const APP_ACTIVITY_PATH = `${USERS_PATH}/activity`;
|
|
51
|
-
/** The child of Users the app activity screen is. */
|
|
52
25
|
export const APP_ACTIVITY_CHILD = 'activity';
|
|
53
|
-
/** Where the signed-in admin's change-password form posts. */
|
|
54
26
|
export const CHANGE_PASSWORD_PATH = `${USERS_PATH}/password`;
|
|
55
|
-
/** Where a delete button posts, on the list or on the user's own screen. */
|
|
56
27
|
export const DELETE_USER_PATH = `${USERS_PATH}/delete`;
|
|
57
|
-
/** Where the email address on the Account panel posts. */
|
|
58
28
|
export const USER_EMAIL_PATH = `${USERS_PATH}/email`;
|
|
59
|
-
/**
|
|
60
|
-
* Where the Profile panel posts.
|
|
61
|
-
*
|
|
62
|
-
* A path of its own rather than a second half of the email form, because the
|
|
63
|
-
* two are about different audiences: an email address is private to the site
|
|
64
|
-
* and a profile is the public face decision-14 puts at the author URL. One
|
|
65
|
-
* form that saved both would mean an admin correcting a colleague's address
|
|
66
|
-
* also republishing their bio.
|
|
67
|
-
*/
|
|
68
29
|
export const USER_PROFILE_PATH = `${USERS_PATH}/profile`;
|
|
69
|
-
/** Where the notice switches post. */
|
|
70
30
|
export const USER_NOTIFICATIONS_PATH = `${USERS_PATH}/notifications`;
|
|
71
|
-
/**
|
|
72
|
-
* Where the how-often selects post.
|
|
73
|
-
*
|
|
74
|
-
* A path of its own rather than a second field on the switch, because the two
|
|
75
|
-
* forms answer different questions and a switch is a button while a mode is a
|
|
76
|
-
* select and a Save: one handler that had to work out which of the two it had
|
|
77
|
-
* been given would be guessing at something the URL can simply say.
|
|
78
|
-
*/
|
|
79
31
|
export const USER_NOTIFICATION_MODE_PATH = `${USER_NOTIFICATIONS_PATH}/mode`;
|
|
80
|
-
/** Where the Theme panel posts; it sets the signed-in user's own theme and names nobody. */
|
|
81
32
|
export const USER_THEME_PATH = `${USERS_PATH}/theme`;
|
|
82
|
-
/** The fields the forms on these screens submit. */
|
|
83
33
|
export const USER_FIELDS = {
|
|
84
34
|
username: 'username',
|
|
85
35
|
password: 'password',
|
|
@@ -89,349 +39,235 @@ export const USER_FIELDS = {
|
|
|
89
39
|
newPassword: 'new_password',
|
|
90
40
|
newPasswordConfirmation: 'new_password_confirmation',
|
|
91
41
|
userId: 'user_id',
|
|
92
|
-
/** Which notice a switch is about, by its name in the registry. */
|
|
93
42
|
event: 'event',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
* A checkbox, so a form that turns one off submits nothing at all under this
|
|
98
|
-
* name — which is why the switch is a form of its own per event rather than
|
|
99
|
-
* one form with a checkbox per event: a browser sends no field for an
|
|
100
|
-
* unticked box, and one form could not tell "turned this off" from "did not
|
|
101
|
-
* mention it".
|
|
102
|
-
*/
|
|
43
|
+
// A browser sends no field for an unticked box, so each event's switch is a
|
|
44
|
+
// form of its own.
|
|
103
45
|
on: 'on',
|
|
104
|
-
/** How often that notice should arrive, for an event that offers a choice. */
|
|
105
46
|
mode: 'mode',
|
|
106
|
-
/** The name to print instead of the login (TASK-67). */
|
|
107
47
|
displayName: 'display_name',
|
|
108
|
-
/** A few sentences about this person. */
|
|
109
48
|
bio: 'bio',
|
|
110
|
-
/** Their picture, as a path or a URL. */
|
|
111
49
|
avatar: 'avatar',
|
|
112
|
-
/** What they do, printed beside the name in a bio (TASK-79). */
|
|
113
50
|
jobTitle: 'job_title',
|
|
114
|
-
/** Where they are, as they write it. */
|
|
115
51
|
location: 'location',
|
|
116
|
-
/** Somewhere else they are: one `Label | URL` per line. */
|
|
117
52
|
links: 'links',
|
|
118
|
-
/** The admin's theme: a built-in DaisyUI theme's name, or empty to follow the system. */
|
|
119
53
|
adminTheme: 'admin_theme',
|
|
120
54
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Register the users screens: the list, the add form, and one screen per user
|
|
123
|
-
* where everything about that person is edited.
|
|
124
|
-
*
|
|
125
|
-
* The same split documents.ts makes (TASK-97). The table says who there is;
|
|
126
|
-
* a person's own screen holds their email address, their public profile, what
|
|
127
|
-
* they are emailed about, and — where the account can go — the delete. Every
|
|
128
|
-
* save lands back on that screen, so it shows its own result.
|
|
129
|
-
*
|
|
130
|
-
* One thing is still only ever your own: the password. Changing somebody
|
|
131
|
-
* else's is deliberately not offered — resetting a colleague's password from
|
|
132
|
-
* under them is what `geekity user add` and a fresh account are for, and it
|
|
133
|
-
* keeps the current-password check honest.
|
|
134
|
-
*/
|
|
135
55
|
export function mountUsers(app, options) {
|
|
136
56
|
const { render } = options;
|
|
137
|
-
app.get(USERS_PATH, (c) =>
|
|
138
|
-
app.get(ADD_USER_PATH, (c) =>
|
|
139
|
-
app.post(ADD_USER_PATH,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
57
|
+
app.get(USERS_PATH, (c) => showUsers(c, render));
|
|
58
|
+
app.get(ADD_USER_PATH, (c) => showAddUser(c, render));
|
|
59
|
+
app.post(ADD_USER_PATH, (c) => addUser(c, render));
|
|
60
|
+
app.post(CHANGE_PASSWORD_PATH, (c) => changePassword(c, render));
|
|
61
|
+
app.post(USER_EMAIL_PATH, saveEmail);
|
|
62
|
+
app.post(USER_PROFILE_PATH, (c) => saveProfile(c, render));
|
|
63
|
+
app.post(USER_NOTIFICATIONS_PATH, saveNotification);
|
|
64
|
+
app.post(USER_NOTIFICATION_MODE_PATH, saveNotificationMode);
|
|
65
|
+
app.post(USER_THEME_PATH, saveTheme);
|
|
66
|
+
app.post(DELETE_USER_PATH, removeUser);
|
|
67
|
+
app.get(`${USERS_PATH}/:id`, (c) => showUser(c, render));
|
|
68
|
+
}
|
|
69
|
+
function showUsers(c, render) {
|
|
70
|
+
return render(c, ADMIN_TEMPLATES.usersList, screen(c));
|
|
71
|
+
}
|
|
72
|
+
function showAddUser(c, render) {
|
|
73
|
+
return render(c, ADMIN_TEMPLATES.usersNew, addScreen(c));
|
|
74
|
+
}
|
|
75
|
+
async function addUser(c, render) {
|
|
76
|
+
const body = await c.req.parseBody();
|
|
77
|
+
const username = stringOrEmpty(body[USER_FIELDS.username]).trim();
|
|
78
|
+
const supplied = stringOrEmpty(body[USER_FIELDS.password]);
|
|
79
|
+
const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
|
|
80
|
+
const generate = stringOrEmpty(body[USER_FIELDS.generate]) !== '';
|
|
81
|
+
const password = generate ? generatePassword() : supplied;
|
|
82
|
+
const problems = addUserProblems(username, password, generate, email);
|
|
83
|
+
if (Object.keys(problems).length === 0) {
|
|
84
|
+
try {
|
|
85
|
+
await createUser({
|
|
86
|
+
dataDir: c.var.config.dataDir,
|
|
87
|
+
username,
|
|
88
|
+
password,
|
|
89
|
+
email,
|
|
90
|
+
now: c.var.config.now(),
|
|
91
|
+
});
|
|
162
92
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (!(error instanceof DuplicateUsernameError))
|
|
95
|
+
throw error;
|
|
96
|
+
problems.username = error.message;
|
|
167
97
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
98
|
+
}
|
|
99
|
+
if (Object.keys(problems).length > 0) {
|
|
100
|
+
c.status(400);
|
|
101
|
+
return render(c, ADMIN_TEMPLATES.usersNew, addScreen(c, { addForm: { username, email, generate }, addProblems: problems }));
|
|
102
|
+
}
|
|
103
|
+
return flashAndRedirect(c, 'notice', generate
|
|
104
|
+
? `Added ${username}. Their password is ${password} — copy it now, it is not shown again.`
|
|
105
|
+
: `Added ${username}.`, USERS_PATH);
|
|
106
|
+
}
|
|
107
|
+
async function changePassword(c, render) {
|
|
108
|
+
const session = c.var.session;
|
|
109
|
+
const user = signedInUser(c);
|
|
110
|
+
if (session === undefined || user === undefined)
|
|
174
111
|
return c.redirect(USERS_PATH, 303);
|
|
112
|
+
const body = await c.req.parseBody();
|
|
113
|
+
const current = stringOrEmpty(body[USER_FIELDS.currentPassword]);
|
|
114
|
+
const next = stringOrEmpty(body[USER_FIELDS.newPassword]);
|
|
115
|
+
const confirmation = stringOrEmpty(body[USER_FIELDS.newPasswordConfirmation]);
|
|
116
|
+
const problems = changePasswordProblems({
|
|
117
|
+
correct: verifyUserPassword(c.var.config.dataDir, user.username, current) !== undefined,
|
|
118
|
+
next,
|
|
119
|
+
confirmation,
|
|
175
120
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* Anybody's, not only your own. There is one role, so every user already has
|
|
216
|
-
* every power there is — including deleting somebody and adding them back —
|
|
217
|
-
* and a screen where an admin could see a colleague's address but not
|
|
218
|
-
* correct a typo in it would be a rule with nothing behind it. It is also
|
|
219
|
-
* what makes a site usable: an admin who has just added a colleague can put
|
|
220
|
-
* their address in without waiting for them to sign in and do it.
|
|
221
|
-
*
|
|
222
|
-
* A flash and a redirect back to that person's screen rather than a 400 with
|
|
223
|
-
* the form redrawn, unlike the two forms above: nothing here is a secret, so
|
|
224
|
-
* there is no reason not to show the refusal beside the box it is about with
|
|
225
|
-
* what is stored back in it.
|
|
226
|
-
*/
|
|
227
|
-
app.post(USER_EMAIL_PATH, async (c) => {
|
|
228
|
-
const named = await namedUser(c);
|
|
229
|
-
if (named instanceof Response)
|
|
230
|
-
return named;
|
|
231
|
-
const { dataDir, body, target } = named;
|
|
232
|
-
const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
|
|
233
|
-
const problem = emailProblem(email);
|
|
234
|
-
if (problem !== undefined) {
|
|
235
|
-
flash(c, 'error', problem);
|
|
236
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
237
|
-
}
|
|
238
|
-
await setUserEmail({ dataDir, userId: target.id, email });
|
|
239
|
-
flash(c, 'notice', email === ''
|
|
240
|
-
? `${target.username} has no email address any more.`
|
|
241
|
-
: `${target.username} will be emailed at ${email}.`);
|
|
242
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
243
|
-
});
|
|
244
|
-
/**
|
|
245
|
-
* Write a user's public profile (TASK-67).
|
|
246
|
-
*
|
|
247
|
-
* Anybody's, for the reason the email field is anybody's: one role, and an
|
|
248
|
-
* admin who has just added a colleague should be able to put a name and a
|
|
249
|
-
* line about them on their archive without waiting for them to sign in. The
|
|
250
|
-
* whole profile at once, because that is what the panel is — six boxes and
|
|
251
|
-
* one Save — and a box somebody cleared is a field they no longer want.
|
|
252
|
-
*
|
|
253
|
-
* A flash and a redirect for everything but the Links box, because nothing
|
|
254
|
-
* else here can be wrong enough to refuse. A link line that is not a link is
|
|
255
|
-
* refused the way a menu line is (TASK-112): a 400 with the panel redrawn
|
|
256
|
-
* around what was typed, because a link nobody can follow is worse stored
|
|
257
|
-
* than reported, and because the line to fix has to still be there to fix.
|
|
258
|
-
*/
|
|
259
|
-
app.post(USER_PROFILE_PATH, async (c) => {
|
|
260
|
-
const named = await namedUser(c);
|
|
261
|
-
if (named instanceof Response)
|
|
262
|
-
return named;
|
|
263
|
-
const { dataDir, body, target } = named;
|
|
264
|
-
const typed = {
|
|
265
|
-
displayName: stringOrEmpty(body[USER_FIELDS.displayName]),
|
|
266
|
-
bio: stringOrEmpty(body[USER_FIELDS.bio]),
|
|
267
|
-
avatar: stringOrEmpty(body[USER_FIELDS.avatar]),
|
|
268
|
-
jobTitle: stringOrEmpty(body[USER_FIELDS.jobTitle]),
|
|
269
|
-
location: stringOrEmpty(body[USER_FIELDS.location]),
|
|
270
|
-
links: stringOrEmpty(body[USER_FIELDS.links]),
|
|
271
|
-
};
|
|
272
|
-
const problem = profileLinkLineProblem(typed.links);
|
|
273
|
-
if (problem !== undefined) {
|
|
274
|
-
c.status(400);
|
|
275
|
-
// Every box comes back holding exactly what was typed into it, the way
|
|
276
|
-
// the Navigation screen's does: a refused save that emptied the panel
|
|
277
|
-
// would cost somebody their bio to report a bad link.
|
|
278
|
-
return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, target, { profileProblems: { links: problem } }, typed));
|
|
279
|
-
}
|
|
280
|
-
const changed = await setUserProfile({
|
|
281
|
-
dataDir,
|
|
282
|
-
userId: target.id,
|
|
283
|
-
profile: { ...typed, links: parseProfileLinks(typed.links) },
|
|
284
|
-
});
|
|
285
|
-
// The profile is the actor's profile now (decision-14), so saving it is
|
|
286
|
-
// also an announcement: a follower's copy of somebody's name, bio and
|
|
287
|
-
// picture is only as fresh as the last `Update` they were sent. The user
|
|
288
|
-
// is read back rather than assumed, so the actor that goes out is built
|
|
289
|
-
// from the file exactly as a peer fetching it would be.
|
|
290
|
-
const saved = changed ? findUserById(dataDir, target.id) : undefined;
|
|
291
|
-
const told = saved === undefined ? undefined : await c.var.delivery.updateActor(saved);
|
|
292
|
-
flash(c, 'notice', `Saved ${target.username}’s profile.${toldFollowers(told)}`);
|
|
293
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
294
|
-
});
|
|
295
|
-
/**
|
|
296
|
-
* Turn one notice on or off for one user.
|
|
297
|
-
*
|
|
298
|
-
* Anybody's, for the reason the email field is anybody's: one role, and an
|
|
299
|
-
* admin who has just given a colleague an address should be able to say what
|
|
300
|
-
* goes to it. An event nothing in this version knows is a no-op rather than an
|
|
301
|
-
* error, because the only way to submit one is a form this CMS did not
|
|
302
|
-
* render.
|
|
303
|
-
*/
|
|
304
|
-
app.post(USER_NOTIFICATIONS_PATH, async (c) => {
|
|
305
|
-
const named = await namedUser(c);
|
|
306
|
-
if (named instanceof Response)
|
|
307
|
-
return named;
|
|
308
|
-
const { dataDir, body, target } = named;
|
|
309
|
-
const name = stringOrEmpty(body[USER_FIELDS.event]);
|
|
310
|
-
const event = notificationEvent(name);
|
|
311
|
-
if (event === undefined) {
|
|
312
|
-
flash(c, 'error', 'That is not something this site can tell anybody about.');
|
|
313
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
314
|
-
}
|
|
315
|
-
// An unticked checkbox submits no field at all, so its absence is the
|
|
316
|
-
// answer rather than a missing one.
|
|
317
|
-
const on = stringOrEmpty(body[USER_FIELDS.on]) !== '';
|
|
318
|
-
await setUserNotification({ dataDir, userId: target.id, event: name, on });
|
|
319
|
-
flash(c, 'notice', on
|
|
320
|
-
? `${target.username} will be emailed about ${event.label.toLowerCase()}.`
|
|
321
|
-
: `${target.username} will not be emailed about ${event.label.toLowerCase()}.`);
|
|
322
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
323
|
-
});
|
|
324
|
-
/**
|
|
325
|
-
* Say how often one notice reaches one user.
|
|
326
|
-
*
|
|
327
|
-
* Anybody's, for the reason the switch beside it is anybody's. A mode this
|
|
328
|
-
* version does not know, or an event that offers no choice, changes nothing
|
|
329
|
-
* and says so: the only way to submit either is a form this CMS did not
|
|
330
|
-
* render.
|
|
331
|
-
*/
|
|
332
|
-
app.post(USER_NOTIFICATION_MODE_PATH, async (c) => {
|
|
333
|
-
const named = await namedUser(c);
|
|
334
|
-
if (named instanceof Response)
|
|
335
|
-
return named;
|
|
336
|
-
const { dataDir, body, target } = named;
|
|
337
|
-
const name = stringOrEmpty(body[USER_FIELDS.event]);
|
|
338
|
-
const event = notificationEvent(name);
|
|
339
|
-
if (event === undefined || !event.batched) {
|
|
340
|
-
flash(c, 'error', 'That is not a notice this site can batch up.');
|
|
341
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
342
|
-
}
|
|
343
|
-
const wanted = deliveryMode(stringOrEmpty(body[USER_FIELDS.mode]));
|
|
344
|
-
if (wanted === undefined) {
|
|
345
|
-
flash(c, 'error', 'That is not one of the choices.');
|
|
346
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
347
|
-
}
|
|
348
|
-
await setUserNotificationMode({ dataDir, userId: target.id, event: name, mode: wanted });
|
|
349
|
-
flash(c, 'notice', wanted === DEFAULT_DELIVERY_MODE
|
|
350
|
-
? `${target.username} will hear about ${event.label.toLowerCase()} as they arrive.`
|
|
351
|
-
: `${target.username} will get one ${wanted === 'daily' ? 'daily' : 'hourly'} digest of ` +
|
|
352
|
-
`${event.label.toLowerCase()}.`);
|
|
353
|
-
return c.redirect(editUserPath(target.id), 303);
|
|
354
|
-
});
|
|
355
|
-
app.post(USER_THEME_PATH, async (c) => {
|
|
356
|
-
const dataDir = c.var.config.dataDir;
|
|
357
|
-
const userId = c.var.session?.userId;
|
|
358
|
-
const user = userId == null ? undefined : findUserById(dataDir, userId);
|
|
359
|
-
if (user === undefined)
|
|
360
|
-
return c.redirect(USERS_PATH, 303);
|
|
361
|
-
const body = await c.req.parseBody();
|
|
362
|
-
const wanted = stringOrEmpty(body[USER_FIELDS.adminTheme]);
|
|
363
|
-
const theme = adminTheme(wanted);
|
|
364
|
-
if (wanted !== '' && theme === undefined) {
|
|
365
|
-
flash(c, 'error', 'That is not one of the themes.');
|
|
366
|
-
return c.redirect(editUserPath(user.id), 303);
|
|
367
|
-
}
|
|
368
|
-
await setUserAdminTheme({ dataDir, userId: user.id, theme });
|
|
369
|
-
flash(c, 'notice', theme === undefined
|
|
370
|
-
? "The admin follows your system's light or dark setting."
|
|
371
|
-
: `The admin is drawn in ${ADMIN_THEMES[theme].label} for you.`);
|
|
372
|
-
return c.redirect(editUserPath(user.id), 303);
|
|
121
|
+
if (Object.keys(problems).length > 0) {
|
|
122
|
+
c.status(400);
|
|
123
|
+
return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user, { passwordProblems: problems }));
|
|
124
|
+
}
|
|
125
|
+
await setUserPassword({ dataDir: c.var.config.dataDir, userId: user.id, password: next });
|
|
126
|
+
const ended = c.var.admin.deleteSessionsForUser(user.id, { except: session.id });
|
|
127
|
+
return backToUser(c, 'notice', ended === 0
|
|
128
|
+
? 'Your password was changed.'
|
|
129
|
+
: `Your password was changed, and ${signedOut(ended)} signed out.`, user);
|
|
130
|
+
}
|
|
131
|
+
async function saveEmail(c) {
|
|
132
|
+
const named = await namedUser(c);
|
|
133
|
+
if (named instanceof Response)
|
|
134
|
+
return named;
|
|
135
|
+
const { dataDir, body, target } = named;
|
|
136
|
+
const email = stringOrEmpty(body[USER_FIELDS.email]).trim();
|
|
137
|
+
const problem = emailProblem(email);
|
|
138
|
+
if (problem !== undefined)
|
|
139
|
+
return backToUser(c, 'error', problem, target);
|
|
140
|
+
await setUserEmail({ dataDir, userId: target.id, email });
|
|
141
|
+
return backToUser(c, 'notice', email === ''
|
|
142
|
+
? `${target.username} has no email address any more.`
|
|
143
|
+
: `${target.username} will be emailed at ${email}.`, target);
|
|
144
|
+
}
|
|
145
|
+
async function saveProfile(c, render) {
|
|
146
|
+
const named = await namedUser(c);
|
|
147
|
+
if (named instanceof Response)
|
|
148
|
+
return named;
|
|
149
|
+
const { dataDir, body, target } = named;
|
|
150
|
+
const typed = typedProfile(body);
|
|
151
|
+
const problem = profileLinkLineProblem(typed.links);
|
|
152
|
+
if (problem !== undefined) {
|
|
153
|
+
c.status(400);
|
|
154
|
+
return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, target, { profileProblems: { links: problem } }, typed));
|
|
155
|
+
}
|
|
156
|
+
const changed = await setUserProfile({
|
|
157
|
+
dataDir,
|
|
158
|
+
userId: target.id,
|
|
159
|
+
profile: { ...typed, links: parseProfileLinks(typed.links) },
|
|
373
160
|
});
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
161
|
+
// A follower's copy of somebody's name, bio and picture is only as fresh as
|
|
162
|
+
// the last `Update` they were sent.
|
|
163
|
+
const saved = changed ? findUserById(dataDir, target.id) : undefined;
|
|
164
|
+
const told = saved === undefined ? undefined : await c.var.delivery.updateActor(saved);
|
|
165
|
+
return backToUser(c, 'notice', `Saved ${target.username}’s profile.${toldFollowers(told)}`, target);
|
|
166
|
+
}
|
|
167
|
+
function typedProfile(body) {
|
|
168
|
+
return {
|
|
169
|
+
displayName: stringOrEmpty(body[USER_FIELDS.displayName]),
|
|
170
|
+
bio: stringOrEmpty(body[USER_FIELDS.bio]),
|
|
171
|
+
avatar: stringOrEmpty(body[USER_FIELDS.avatar]),
|
|
172
|
+
jobTitle: stringOrEmpty(body[USER_FIELDS.jobTitle]),
|
|
173
|
+
location: stringOrEmpty(body[USER_FIELDS.location]),
|
|
174
|
+
links: stringOrEmpty(body[USER_FIELDS.links]),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async function saveNotification(c) {
|
|
178
|
+
const named = await namedUser(c);
|
|
179
|
+
if (named instanceof Response)
|
|
180
|
+
return named;
|
|
181
|
+
const { dataDir, body, target } = named;
|
|
182
|
+
const name = stringOrEmpty(body[USER_FIELDS.event]);
|
|
183
|
+
const event = notificationEvent(name);
|
|
184
|
+
if (event === undefined) {
|
|
185
|
+
return backToUser(c, 'error', 'That is not something this site can tell anybody about.', target);
|
|
186
|
+
}
|
|
187
|
+
// An unticked checkbox submits no field at all, so its absence is the
|
|
188
|
+
// answer rather than a missing one.
|
|
189
|
+
const on = stringOrEmpty(body[USER_FIELDS.on]) !== '';
|
|
190
|
+
await setUserNotification({ dataDir, userId: target.id, event: name, on });
|
|
191
|
+
return backToUser(c, 'notice', on
|
|
192
|
+
? `${target.username} will be emailed about ${event.label.toLowerCase()}.`
|
|
193
|
+
: `${target.username} will not be emailed about ${event.label.toLowerCase()}.`, target);
|
|
194
|
+
}
|
|
195
|
+
async function saveNotificationMode(c) {
|
|
196
|
+
const named = await namedUser(c);
|
|
197
|
+
if (named instanceof Response)
|
|
198
|
+
return named;
|
|
199
|
+
const { dataDir, body, target } = named;
|
|
200
|
+
const name = stringOrEmpty(body[USER_FIELDS.event]);
|
|
201
|
+
const event = notificationEvent(name);
|
|
202
|
+
if (event === undefined || !event.batched) {
|
|
203
|
+
return backToUser(c, 'error', 'That is not a notice this site can batch up.', target);
|
|
204
|
+
}
|
|
205
|
+
const wanted = deliveryMode(stringOrEmpty(body[USER_FIELDS.mode]));
|
|
206
|
+
if (wanted === undefined)
|
|
207
|
+
return backToUser(c, 'error', 'That is not one of the choices.', target);
|
|
208
|
+
await setUserNotificationMode({ dataDir, userId: target.id, event: name, mode: wanted });
|
|
209
|
+
return backToUser(c, 'notice', wanted === DEFAULT_DELIVERY_MODE
|
|
210
|
+
? `${target.username} will hear about ${event.label.toLowerCase()} as they arrive.`
|
|
211
|
+
: `${target.username} will get one ${wanted === 'daily' ? 'daily' : 'hourly'} digest of ` +
|
|
212
|
+
`${event.label.toLowerCase()}.`, target);
|
|
213
|
+
}
|
|
214
|
+
async function saveTheme(c) {
|
|
215
|
+
const user = signedInUser(c);
|
|
216
|
+
if (user === undefined)
|
|
395
217
|
return c.redirect(USERS_PATH, 303);
|
|
218
|
+
const body = await c.req.parseBody();
|
|
219
|
+
const wanted = stringOrEmpty(body[USER_FIELDS.adminTheme]);
|
|
220
|
+
const theme = adminTheme(wanted);
|
|
221
|
+
if (wanted !== '' && theme === undefined) {
|
|
222
|
+
return backToUser(c, 'error', 'That is not one of the themes.', user);
|
|
223
|
+
}
|
|
224
|
+
await setUserAdminTheme({ dataDir: c.var.config.dataDir, userId: user.id, theme });
|
|
225
|
+
return backToUser(c, 'notice', theme === undefined
|
|
226
|
+
? "The admin follows your system's light or dark setting."
|
|
227
|
+
: `The admin is drawn in ${ADMIN_THEMES[theme].label} for you.`, user);
|
|
228
|
+
}
|
|
229
|
+
async function removeUser(c) {
|
|
230
|
+
const dataDir = c.var.config.dataDir;
|
|
231
|
+
const target = userInForm(dataDir, await c.req.parseBody());
|
|
232
|
+
const refusal = deleteUserRefusal({
|
|
233
|
+
target,
|
|
234
|
+
signedInAs: c.var.session?.userId ?? null,
|
|
235
|
+
total: countUsers(dataDir),
|
|
396
236
|
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
237
|
+
if (refusal !== undefined || target === undefined) {
|
|
238
|
+
return flashAndRedirect(c, 'error', refusal ?? GONE_USER, USERS_PATH);
|
|
239
|
+
}
|
|
240
|
+
await deleteUser({ dataDir, userId: target.id, now: c.var.config.now() });
|
|
241
|
+
c.var.admin.deleteSessionsForUser(target.id);
|
|
242
|
+
return flashAndRedirect(c, 'notice', `Deleted ${target.username}.`, USERS_PATH);
|
|
243
|
+
}
|
|
244
|
+
function showUser(c, render) {
|
|
245
|
+
const id = pathId(c.req.param('id') ?? '');
|
|
246
|
+
const user = id === undefined ? undefined : findUserById(c.var.config.dataDir, id);
|
|
247
|
+
if (user === undefined)
|
|
248
|
+
return c.notFound();
|
|
249
|
+
return render(c, ADMIN_TEMPLATES.usersEdit, userScreen(c, user));
|
|
250
|
+
}
|
|
251
|
+
function backToUser(c, kind, message, user) {
|
|
252
|
+
return flashAndRedirect(c, kind, message, editUserPath(user.id));
|
|
253
|
+
}
|
|
254
|
+
function userInForm(dataDir, body) {
|
|
255
|
+
const id = Number(stringOrEmpty(body[USER_FIELDS.userId]));
|
|
256
|
+
return Number.isInteger(id) ? findUserById(dataDir, id) : undefined;
|
|
257
|
+
}
|
|
258
|
+
function signedInUser(c) {
|
|
259
|
+
const userId = c.var.session?.userId;
|
|
260
|
+
return userId == null ? undefined : findUserById(c.var.config.dataDir, userId);
|
|
411
261
|
}
|
|
412
262
|
async function namedUser(c) {
|
|
413
263
|
const dataDir = c.var.config.dataDir;
|
|
414
264
|
const body = await c.req.parseBody();
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
flash(c, 'error', GONE_USER);
|
|
419
|
-
return c.redirect(USERS_PATH, 303);
|
|
420
|
-
}
|
|
265
|
+
const target = userInForm(dataDir, body);
|
|
266
|
+
if (target === undefined)
|
|
267
|
+
return flashAndRedirect(c, 'error', GONE_USER, USERS_PATH);
|
|
421
268
|
return { dataDir, body, target };
|
|
422
269
|
}
|
|
423
270
|
const GONE_USER = 'That user is already gone.';
|
|
424
|
-
/**
|
|
425
|
-
* Take a user out of the file. Returns `false` when there was nothing to take.
|
|
426
|
-
*
|
|
427
|
-
* Their IndieAuth tokens go with them (TASK-160): a token is a file in
|
|
428
|
-
* `data/` too, so it is revoked here, where every caller deletes a user.
|
|
429
|
-
*
|
|
430
|
-
* Their sessions are not ended here: sessions are in the database, and the
|
|
431
|
-
* screen that deletes a user ends them itself. A session that outlives this —
|
|
432
|
-
* one in a database restored from a backup, say — names a user the file no
|
|
433
|
-
* longer holds, and the admin guard turns that into no session at all.
|
|
434
|
-
*/
|
|
435
271
|
export async function deleteUser(input) {
|
|
436
272
|
const deleted = await removeUserRecord(input);
|
|
437
273
|
await revokeTokensForUser(input.dataDir, input.userId, input.now);
|
|
@@ -439,15 +275,6 @@ export async function deleteUser(input) {
|
|
|
439
275
|
discardWritingLedger(input.dataDir, input.userId);
|
|
440
276
|
return deleted;
|
|
441
277
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Delete a user.
|
|
444
|
-
*
|
|
445
|
-
* Two refusals, in this order. The last remaining user cannot go, because a
|
|
446
|
-
* site with no users falls back into first-run setup and anybody who reaches
|
|
447
|
-
* it becomes its admin. And nobody may delete their own account: it would end
|
|
448
|
-
* the session doing the deleting, and there is no undo. Both are a flash and a
|
|
449
|
-
* redirect rather than a 400, because nothing was typed to send back.
|
|
450
|
-
*/
|
|
451
278
|
export function deleteUserRefusal(input) {
|
|
452
279
|
if (input.target === undefined)
|
|
453
280
|
return GONE_USER;
|
|
@@ -459,12 +286,6 @@ export function deleteUserRefusal(input) {
|
|
|
459
286
|
}
|
|
460
287
|
return undefined;
|
|
461
288
|
}
|
|
462
|
-
/**
|
|
463
|
-
* What is wrong with a proposed password change, one message per field.
|
|
464
|
-
*
|
|
465
|
-
* The current password is taken as already checked, rather than checked here,
|
|
466
|
-
* so this stays a pure function over what the store said.
|
|
467
|
-
*/
|
|
468
289
|
export function changePasswordProblems(input) {
|
|
469
290
|
const problems = {};
|
|
470
291
|
if (!input.correct)
|
|
@@ -477,20 +298,9 @@ export function changePasswordProblems(input) {
|
|
|
477
298
|
}
|
|
478
299
|
return problems;
|
|
479
300
|
}
|
|
480
|
-
/** "1 other session was" or "3 other sessions were", for the flash. */
|
|
481
301
|
function signedOut(count) {
|
|
482
302
|
return count === 1 ? '1 other session was' : `${String(count)} other sessions were`;
|
|
483
303
|
}
|
|
484
|
-
/**
|
|
485
|
-
* What is wrong with a proposed user, one message per field.
|
|
486
|
-
*
|
|
487
|
-
* The rules are the shared ones, so an account made here is one
|
|
488
|
-
* `/admin/setup` and `geekity user add` would both have accepted. A generated
|
|
489
|
-
* password is not checked against them — it is made to satisfy them — and the
|
|
490
|
-
* password field is not read at all when the box is ticked, so a stale value
|
|
491
|
-
* left in it cannot be what is refused. An empty email is not a problem: it is
|
|
492
|
-
* an optional field, and most users will never have one.
|
|
493
|
-
*/
|
|
494
304
|
export function addUserProblems(username, password, generate = false, email = '') {
|
|
495
305
|
const problems = {};
|
|
496
306
|
const name = usernameProblem(username);
|
|
@@ -506,14 +316,8 @@ export function addUserProblems(username, password, generate = false, email = ''
|
|
|
506
316
|
problems.email = address;
|
|
507
317
|
return problems;
|
|
508
318
|
}
|
|
509
|
-
/**
|
|
510
|
-
* The alphabet a generated password is drawn from: no `0`/`O` and no `1`/`l`,
|
|
511
|
-
* because a generated password is read off a screen and typed somewhere else.
|
|
512
|
-
*/
|
|
513
319
|
export const GENERATED_PASSWORD_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789';
|
|
514
|
-
/** How many characters a generated password has. 20 is about 116 bits here. */
|
|
515
320
|
export const GENERATED_PASSWORD_LENGTH = 20;
|
|
516
|
-
/** A password nobody chose, from `randomInt` rather than `Math.random`. */
|
|
517
321
|
export function generatePassword() {
|
|
518
322
|
let password = '';
|
|
519
323
|
for (let index = 0; index < GENERATED_PASSWORD_LENGTH; index += 1) {
|
|
@@ -521,37 +325,14 @@ export function generatePassword() {
|
|
|
521
325
|
}
|
|
522
326
|
return password;
|
|
523
327
|
}
|
|
524
|
-
/**
|
|
525
|
-
* The Add new screen: the same context the listing is drawn from, rendered
|
|
526
|
-
* through `pages/users/new.njk` instead. The two screens are the same chrome
|
|
527
|
-
* around one of two things, and which of them it is is the route's business
|
|
528
|
-
* rather than a flag the template has to read.
|
|
529
|
-
*/
|
|
530
328
|
function addScreen(c, extra = {}) {
|
|
531
329
|
return screen(c, { child: 'new', ...extra });
|
|
532
330
|
}
|
|
533
|
-
|
|
534
|
-
* Everything one user's screen renders (TASK-97).
|
|
535
|
-
*
|
|
536
|
-
* The same forms the table used to hold, one per panel and each with its
|
|
537
|
-
* fields labelled: the account, the public profile, what this person is
|
|
538
|
-
* emailed about, the password — only on your own page — and the delete, or the
|
|
539
|
-
* sentence saying why this account cannot go.
|
|
540
|
-
*/
|
|
541
|
-
function userScreen(c, user, extra = {},
|
|
542
|
-
/**
|
|
543
|
-
* What was typed into the Profile panel, where a save of it was refused: the
|
|
544
|
-
* boxes are drawn holding this instead of what is stored, so the line to fix
|
|
545
|
-
* is still on the screen and nothing else somebody wrote has been thrown
|
|
546
|
-
* away (TASK-112).
|
|
547
|
-
*/
|
|
548
|
-
typedProfile) {
|
|
331
|
+
function userScreen(c, user, extra = {}, typedProfile) {
|
|
549
332
|
const signedInAs = c.var.session?.userId ?? null;
|
|
550
333
|
const total = countUsers(c.var.config.dataDir);
|
|
551
334
|
return {
|
|
552
335
|
section: 'users',
|
|
553
|
-
// The list's entry stays marked: an edit screen is where a row goes, not a
|
|
554
|
-
// sixth thing in the menu.
|
|
555
336
|
child: 'all',
|
|
556
337
|
usersUrl: USERS_PATH,
|
|
557
338
|
userProfileUrl: USER_PROFILE_PATH,
|
|
@@ -564,15 +345,10 @@ typedProfile) {
|
|
|
564
345
|
userThemeUrl: USER_THEME_PATH,
|
|
565
346
|
themeChoices: themeChoices(user),
|
|
566
347
|
fields: USER_FIELDS,
|
|
567
|
-
// `account` rather than `user`, which the chrome already holds: the bar
|
|
568
|
-
// says who is signed in, and this screen is about somebody who may well be
|
|
569
|
-
// anybody else.
|
|
570
348
|
account: {
|
|
571
349
|
...row(user, { signedInAs, total }),
|
|
572
350
|
...(typedProfile === undefined ? {} : { profile: typedProfile }),
|
|
573
351
|
},
|
|
574
|
-
// Why this account cannot go, where it cannot, so the screen says it
|
|
575
|
-
// instead of offering a button it is about to refuse.
|
|
576
352
|
deleteRefusal: deleteUserRefusal({ target: user, signedInAs, total }),
|
|
577
353
|
passwordProblems: {},
|
|
578
354
|
profileProblems: {},
|
|
@@ -580,14 +356,6 @@ typedProfile) {
|
|
|
580
356
|
...extra,
|
|
581
357
|
};
|
|
582
358
|
}
|
|
583
|
-
/**
|
|
584
|
-
* Everything the users screens render: the listing, and the fields the add
|
|
585
|
-
* form is drawn from.
|
|
586
|
-
*
|
|
587
|
-
* Nothing about editing a user is here any more (TASK-97). A row says who
|
|
588
|
-
* somebody is and links to their screen; the only form in the table is the
|
|
589
|
-
* delete, which is an action rather than a field.
|
|
590
|
-
*/
|
|
591
359
|
function screen(c, extra = {}) {
|
|
592
360
|
const signedInAs = c.var.session?.userId ?? null;
|
|
593
361
|
const users = listUsers(c.var.config.dataDir);
|
|
@@ -614,42 +382,9 @@ function themeChoices(user) {
|
|
|
614
382
|
})),
|
|
615
383
|
];
|
|
616
384
|
}
|
|
617
|
-
/**
|
|
618
|
-
* A textarea of links as the list a profile stores: one per line, `Label |
|
|
619
|
-
* URL`, or a bare URL that labels itself.
|
|
620
|
-
*
|
|
621
|
-
* A textarea rather than a repeating fieldset because a profile has two or
|
|
622
|
-
* three links and a table row has no space for a widget; the separator is a
|
|
623
|
-
* pipe because it is the one character nobody puts in a link label by
|
|
624
|
-
* accident. Blank lines are skipped and the empties are dropped inside
|
|
625
|
-
* `setUserProfile`, so a list somebody emptied leaves no key behind.
|
|
626
|
-
*/
|
|
627
385
|
export function parseProfileLinks(value) {
|
|
628
386
|
return profileLinkLines(value).map(profileLinkFields);
|
|
629
387
|
}
|
|
630
|
-
/**
|
|
631
|
-
* What is wrong with a typed list of profile links, or `undefined` when
|
|
632
|
-
* nothing is.
|
|
633
|
-
*
|
|
634
|
-
* The check the box never had (TASK-112). A URL goes through
|
|
635
|
-
* {@link isLinkUrl}, the rule the Navigation screen's menu box already used,
|
|
636
|
-
* so `Elsewhere | not a url` is refused in both places and for the same
|
|
637
|
-
* reason. One message naming the first bad line, for the reason the menu box's
|
|
638
|
-
* message names one: a box is fixed a line at a time, and the line to fix is
|
|
639
|
-
* the useful half of the sentence.
|
|
640
|
-
*
|
|
641
|
-
* The same line as a menu item's, down to the `rel` values it may end in
|
|
642
|
-
* (TASK-114): somebody who learns one box has learned the other, and a
|
|
643
|
-
* trailing `| me` — the line that started all this — is a link rather than a
|
|
644
|
-
* mistake. A profile link is published `rel="me"` either way, so typing it is
|
|
645
|
-
* a no-op; typing `| me nofollow author` is three values on the rendered
|
|
646
|
-
* attribute.
|
|
647
|
-
*
|
|
648
|
-
* Tolerant on the way out and strict on the way in: {@link parseProfileLinks}
|
|
649
|
-
* and the file's own reader still take anything, so a link stored before this
|
|
650
|
-
* check existed still renders and still comes back in the box. Refusing a save
|
|
651
|
-
* is not refusing a read.
|
|
652
|
-
*/
|
|
653
388
|
export function profileLinkLineProblem(value) {
|
|
654
389
|
const bad = profileLinkLines(value).find((line) => !isProfileLink(profileLinkFields(line)));
|
|
655
390
|
if (bad === undefined)
|
|
@@ -658,24 +393,12 @@ export function profileLinkLineProblem(value) {
|
|
|
658
393
|
`per line, where the URL is ${LINK_URL_RULE}, and may end in ` +
|
|
659
394
|
`${LINK_REL_RULE}. "${bad}" is not one.`);
|
|
660
395
|
}
|
|
661
|
-
/** The non-empty lines of the Links box, trimmed. A blank line asks for nothing. */
|
|
662
396
|
function profileLinkLines(value) {
|
|
663
397
|
return value
|
|
664
398
|
.split('\n')
|
|
665
399
|
.map((line) => line.trim())
|
|
666
400
|
.filter((line) => line !== '');
|
|
667
401
|
}
|
|
668
|
-
/**
|
|
669
|
-
* One typed line split where a profile link splits: its `rel` values off the
|
|
670
|
-
* end, then at its first bar, so a label cannot hold one and a line with no
|
|
671
|
-
* bar left is a URL that labels itself.
|
|
672
|
-
*
|
|
673
|
-
* The split alone, with nothing said about whether what came out is a link:
|
|
674
|
-
* one spelling for the line the box reads back and the line it checks, so the
|
|
675
|
-
* two can never disagree about which half is the URL. The tail comes off
|
|
676
|
-
* through {@link splitLinkRel}, the same call the menu box makes, which is
|
|
677
|
-
* what makes the two boxes one line format (TASK-114).
|
|
678
|
-
*/
|
|
679
402
|
function profileLinkFields(line) {
|
|
680
403
|
const { text, rel } = splitLinkRel(line);
|
|
681
404
|
const carried = rel === '' ? {} : { rel };
|
|
@@ -684,11 +407,9 @@ function profileLinkFields(line) {
|
|
|
684
407
|
return { label: text, href: text, ...carried };
|
|
685
408
|
return { label: text.slice(0, bar).trim(), href: text.slice(bar + 1).trim(), ...carried };
|
|
686
409
|
}
|
|
687
|
-
/** Whether a split line is a link: somewhere to go, and something to call it. */
|
|
688
410
|
function isProfileLink(link) {
|
|
689
411
|
return link.label !== '' && isLinkUrl(link.href);
|
|
690
412
|
}
|
|
691
|
-
/** A stored list of links back as the textarea shows it. */
|
|
692
413
|
export function formatProfileLinks(links) {
|
|
693
414
|
return (links ?? [])
|
|
694
415
|
.map((link) => {
|
|
@@ -697,18 +418,13 @@ export function formatProfileLinks(links) {
|
|
|
697
418
|
})
|
|
698
419
|
.join('\n');
|
|
699
420
|
}
|
|
700
|
-
/** One user, as the table lists them and as their own screen edits them. */
|
|
701
421
|
function row(user, context) {
|
|
702
422
|
const you = user.id === context.signedInAs;
|
|
703
423
|
return {
|
|
704
424
|
id: user.id,
|
|
705
425
|
username: user.username,
|
|
706
426
|
email: user.email ?? '',
|
|
707
|
-
// Where the row goes, and where every save about this person lands.
|
|
708
427
|
editUrl: editUserPath(user.id),
|
|
709
|
-
// The public half of this person (TASK-67): what the archive at
|
|
710
|
-
// `archiveUrl` is headed with, and — after TASK-68 — what their actor
|
|
711
|
-
// carries.
|
|
712
428
|
profile: {
|
|
713
429
|
displayName: user.profile?.displayName ?? '',
|
|
714
430
|
bio: user.profile?.bio ?? '',
|
|
@@ -718,20 +434,10 @@ function row(user, context) {
|
|
|
718
434
|
links: formatProfileLinks(user.profile?.links),
|
|
719
435
|
},
|
|
720
436
|
archiveUrl: authorHref(user.username),
|
|
721
|
-
// The id this person was published under before they were here (TASK-69).
|
|
722
|
-
// Shown on their screen rather than edited: it is identity, not a
|
|
723
|
-
// preference — the import writes it, or somebody editing
|
|
724
|
-
// `data/users.json` does — and a box that let it be changed would be a box
|
|
725
|
-
// that could break every follow this person has. Empty for almost
|
|
726
|
-
// everybody, and then the screen says nothing about it at all.
|
|
727
437
|
storedActorId: user.actorId ?? '',
|
|
728
|
-
// One switch per registered event, so the screen loops rather than naming
|
|
729
|
-
// the notices it happens to know about (TASK-55).
|
|
730
438
|
notifications: notificationSwitches(user),
|
|
731
439
|
createdAt: user.createdAt,
|
|
732
440
|
you,
|
|
733
|
-
// The button is rendered for everybody the signed-in admin may actually
|
|
734
|
-
// delete, so neither screen offers an action it is about to refuse.
|
|
735
441
|
deletable: !you && context.total > 1,
|
|
736
442
|
};
|
|
737
443
|
}
|