Remove ability for users to delete themselves

This commit is contained in:
Toby Zerner 2015-08-04 21:35:41 +09:30
parent 5bcfea73cc
commit e0124e72a9
5 changed files with 1 additions and 88 deletions

View File

@ -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 (
<div className="Modal-body">
<div className="Form Form--centered">
<div className="helpText">
<p>{app.trans('core.delete_account_help')}</p>
<ul>
<li>{app.trans('core.username_will_be_released')}</li>
<li>{app.trans('core.posts_will_remain')}</li>
</ul>
</div>
<div className="Form-group">
<input className="FormControl"
name="confirm"
placeholder="Type 'DELETE' to proceed"
oninput={m.withAttr('value', this.confirmation)}/>
</div>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary Button--block',
type: 'submit',
loading: this.loading,
disabled: this.confirmation() !== 'DELETE',
children: app.trans('core.delete_account')
})}
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
if (this.confirmation() !== 'DELETE') return;
this.loading = true;
app.session.user.delete().then(() => app.session.logout());
}
}

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}

View File

@ -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',