allow deleting account on mitra
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1422,6 +1422,17 @@ class PlApiClient {
|
||||
return response.json as {};
|
||||
},
|
||||
|
||||
/**
|
||||
* Requires features{@link Features['deleteAccountWithoutPassword']}.
|
||||
*/
|
||||
deleteAccountWithoutPassword: async () => {
|
||||
const response = await this.request('/api/v1/settings/delete_account', {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
return response.json as {};
|
||||
},
|
||||
|
||||
/**
|
||||
* Disable an account
|
||||
*
|
||||
|
||||
@ -510,6 +510,11 @@ const getFeatures = (instance: Instance) => {
|
||||
v.software === PLEROMA,
|
||||
]),
|
||||
|
||||
/**
|
||||
* @see POST /api/v1/settings/delete_account
|
||||
*/
|
||||
deleteAccountWithoutPassword: v.software === MITRA && gte(v.version, '2.14.0'),
|
||||
|
||||
/**
|
||||
* Allow to register on a given domain
|
||||
* @see GET /api/v1/pleroma/admin/domains
|
||||
|
||||
@ -36,7 +36,9 @@ const deleteAccount = (password: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const account = getLoggedInAccount(getState())!;
|
||||
|
||||
return getClient(getState).settings.deleteAccount(password).then(() => {
|
||||
const client = getClient(getState);
|
||||
|
||||
return (client.features.deleteAccount ? client.settings.deleteAccount(password) : client.settings.deleteAccountWithoutPassword()).then(() => {
|
||||
dispatch<SecurityAction>({ type: AUTH_LOGGED_OUT, account });
|
||||
toast.success(messages.loggedOut);
|
||||
});
|
||||
|
||||
@ -17,8 +17,8 @@ import toast from 'pl-fe/toast';
|
||||
const messages = defineMessages({
|
||||
passwordFieldLabel: { id: 'security.fields.password.label', defaultMessage: 'Password' },
|
||||
deleteHeader: { id: 'security.headers.delete', defaultMessage: 'Delete account' },
|
||||
deleteText: { id: 'security.text.delete', defaultMessage: 'To delete your account, enter your password then click Delete Account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It\'s not guaranteed that all servers will purge your account.' },
|
||||
localDeleteText: { id: 'security.text.delete.local', defaultMessage: 'To delete your account, enter your password then click Delete Account. This is a permanent action that cannot be undone.' },
|
||||
deleteText: { id: 'security.text.delete', defaultMessage: 'To delete your account, enter your password and then click Delete account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It\'s not guaranteed that all servers will purge your account.' },
|
||||
localDeleteText: { id: 'security.text.delete.local', defaultMessage: 'To delete your account, enter your password and then click Delete account. This is a permanent action that cannot be undone.' },
|
||||
deleteSubmit: { id: 'security.submit.delete', defaultMessage: 'Delete account' },
|
||||
deleteAccountSuccess: { id: 'security.delete_account.success', defaultMessage: 'Account successfully deleted.' },
|
||||
deleteAccountFail: { id: 'security.delete_account.fail', defaultMessage: 'Account deletion failed.' },
|
||||
@ -65,14 +65,16 @@ const DeleteAccount = () => {
|
||||
</Text>
|
||||
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<FormGroup labelText={intl.formatMessage(messages.passwordFieldLabel)}>
|
||||
<Input
|
||||
type='password'
|
||||
name='password'
|
||||
onChange={handleInputChange}
|
||||
value={password}
|
||||
/>
|
||||
</FormGroup>
|
||||
{!features.deleteAccountWithoutPassword && (
|
||||
<FormGroup labelText={intl.formatMessage(messages.passwordFieldLabel)}>
|
||||
<Input
|
||||
type='password'
|
||||
name='password'
|
||||
onChange={handleInputChange}
|
||||
value={password}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
|
||||
<FormActions>
|
||||
<Button type='submit' theme='danger' disabled={isLoading}>
|
||||
|
||||
@ -149,6 +149,7 @@ const Settings = () => {
|
||||
features.federating && features.accountMoving,
|
||||
features.federating && features.manageAccountAliases,
|
||||
features.deleteAccount,
|
||||
features.deleteAccountWithoutPassword,
|
||||
]) && (
|
||||
<>
|
||||
<CardHeader>
|
||||
@ -177,7 +178,7 @@ const Settings = () => {
|
||||
<ListItem label={intl.formatMessage(messages.accountAliases)} to='/settings/aliases' />
|
||||
))}
|
||||
|
||||
{features.deleteAccount && (
|
||||
{features.deleteAccount || features.deleteAccountWithoutPassword && (
|
||||
<ListItem label={<Text theme='danger'>{intl.formatMessage(messages.deleteAccount)}</Text>} to='/settings/account' />
|
||||
)}
|
||||
</List>
|
||||
|
||||
Reference in New Issue
Block a user