From e0124e72a986240160fb67318778c96545a6161b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 4 Aug 2015 21:35:41 +0930 Subject: [PATCH] Remove ability for users to delete themselves --- .../src/components/DeleteAccountModal.js | 70 ------------------- .../js/forum/src/components/SettingsPage.js | 9 --- framework/core/locale/en.yml | 4 -- .../src/Core/Users/UsersServiceProvider.php | 2 +- .../core/src/Forum/Actions/ClientAction.php | 4 -- 5 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 framework/core/js/forum/src/components/DeleteAccountModal.js diff --git a/framework/core/js/forum/src/components/DeleteAccountModal.js b/framework/core/js/forum/src/components/DeleteAccountModal.js deleted file mode 100644 index c8ccdf69c..000000000 --- a/framework/core/js/forum/src/components/DeleteAccountModal.js +++ /dev/null @@ -1,70 +0,0 @@ -import Modal from 'flarum/components/Modal'; -import Button from 'flarum/components/Button'; - -/** - * The `DeleteAccountModal` component shows a modal dialog which allows the user - * to delete their account. - * - * @todo require typing password instead of DELETE - */ -export default class DeleteAccountModal extends Modal { - constructor(props) { - super(props); - - /** - * The value of the confirmation input. - * - * @type {Function} - */ - this.confirmation = m.prop(); - } - - className() { - return 'DeleteAccountModal Modal--small'; - } - - title() { - return app.trans('core.delete_account'); - } - - content() { - return ( -
-
-
-

{app.trans('core.delete_account_help')}

-
    -
  • {app.trans('core.username_will_be_released')}
  • -
  • {app.trans('core.posts_will_remain')}
  • -
-
-
- -
-
- {Button.component({ - className: 'Button Button--primary Button--block', - type: 'submit', - loading: this.loading, - disabled: this.confirmation() !== 'DELETE', - children: app.trans('core.delete_account') - })} -
-
-
- ); - } - - onsubmit(e) { - e.preventDefault(); - - if (this.confirmation() !== 'DELETE') return; - - this.loading = true; - - app.session.user.delete().then(() => app.session.logout()); - } -} diff --git a/framework/core/js/forum/src/components/SettingsPage.js b/framework/core/js/forum/src/components/SettingsPage.js index c17bfb18a..8c1b7c2bf 100644 --- a/framework/core/js/forum/src/components/SettingsPage.js +++ b/framework/core/js/forum/src/components/SettingsPage.js @@ -6,7 +6,6 @@ import FieldSet from 'flarum/components/FieldSet'; import NotificationGrid from 'flarum/components/NotificationGrid'; import ChangePasswordModal from 'flarum/components/ChangePasswordModal'; import ChangeEmailModal from 'flarum/components/ChangeEmailModal'; -import DeleteAccountModal from 'flarum/components/DeleteAccountModal'; import listItems from 'flarum/helpers/listItems'; /** @@ -88,14 +87,6 @@ export default class SettingsPage extends UserPage { }) ); - items.add('deleteAccount', - Button.component({ - children: app.trans('core.delete_account'), - className: 'Button Button--danger', - onclick: () => app.modal.show(new DeleteAccountModal()) - }) - ); - return items; } diff --git a/framework/core/locale/en.yml b/framework/core/locale/en.yml index c0ca3fb4e..9282b19f4 100644 --- a/framework/core/locale/en.yml +++ b/framework/core/locale/en.yml @@ -20,8 +20,6 @@ core: confirmation_email_sent: "We've sent a confirmation email to {email}. If it doesn't arrive soon, check your spam folder." controls: Controls delete: Delete - delete_account: Delete Account - delete_account_help: "Hold up! If you delete your account, there's no going back. Keep in mind:" delete_forever: Delete Forever deleted: "[deleted]" disclose_online: Allow others to see when I am online @@ -75,7 +73,6 @@ core: post_reply: Post Reply posted_a_reply: Posted a reply posts: Posts - posts_will_remain: "All of your posts will remain, but no longer associated with your account." powered_by_flarum: Powered by Flarum privacy: Privacy profile: Profile @@ -104,7 +101,6 @@ core: upload: Upload username: Username username_or_email: Username or Email - username_will_be_released: "Your username will be released, so someone else will be able to sign up with your name." users: Users view: View viewing_posts: diff --git a/framework/core/src/Core/Users/UsersServiceProvider.php b/framework/core/src/Core/Users/UsersServiceProvider.php index 6f2f28feb..97a0bbddd 100644 --- a/framework/core/src/Core/Users/UsersServiceProvider.php +++ b/framework/core/src/Core/Users/UsersServiceProvider.php @@ -28,7 +28,7 @@ class UsersServiceProvider extends ServiceProvider $events->listen(ModelAllow::class, function (ModelAllow $event) { if ($event->model instanceof User) { - if (in_array($event->action, ['edit', 'delete']) && + if ($event->action === 'edit') && $event->model->id == $event->actor->id) { return true; } diff --git a/framework/core/src/Forum/Actions/ClientAction.php b/framework/core/src/Forum/Actions/ClientAction.php index ec9404e9d..4b7dcb371 100644 --- a/framework/core/src/Forum/Actions/ClientAction.php +++ b/framework/core/src/Forum/Actions/ClientAction.php @@ -39,8 +39,6 @@ class ClientAction extends BaseClientAction 'core.confirmation_email_sent', 'core.controls', 'core.delete', - 'core.delete_account', - 'core.delete_account_help', 'core.delete_forever', 'core.deleted', 'core.disclose_online', @@ -94,7 +92,6 @@ class ClientAction extends BaseClientAction 'core.post_reply', 'core.posted_a_reply', 'core.posts', - 'core.posts_will_remain', 'core.powered_by_flarum', 'core.privacy', 'core.profile', @@ -123,7 +120,6 @@ class ClientAction extends BaseClientAction 'core.upload', 'core.username', 'core.username_or_email', - 'core.username_will_be_released', 'core.users', 'core.view', 'core.viewing_posts',