- debugged features/security
- added deactivateAccount method to actions/auth - successful deactivation logs user out
This commit is contained in:
parent
8827b5ffd6
commit
a2bd359c76
|
@ -19,6 +19,10 @@ export const CHANGE_EMAIL_REQUEST = 'CHANGE_EMAIL_REQUEST';
|
||||||
export const CHANGE_EMAIL_SUCCESS = 'CHANGE_EMAIL_SUCCESS';
|
export const CHANGE_EMAIL_SUCCESS = 'CHANGE_EMAIL_SUCCESS';
|
||||||
export const CHANGE_EMAIL_FAIL = 'CHANGE_EMAIL_FAIL';
|
export const CHANGE_EMAIL_FAIL = 'CHANGE_EMAIL_FAIL';
|
||||||
|
|
||||||
|
export const DEACTIVATE_ACCOUNT_REQUEST = 'DEACTIVATE_ACCOUNT_REQUEST';
|
||||||
|
export const DEACTIVATE_ACCOUNT_SUCCESS = 'DEACTIVATE_ACCOUNT_SUCCESS';
|
||||||
|
export const DEACTIVATE_ACCOUNT_FAIL = 'DEACTIVATE_ACCOUNT_FAIL';
|
||||||
|
|
||||||
export const CHANGE_PASSWORD_REQUEST = 'CHANGE_PASSWORD_REQUEST';
|
export const CHANGE_PASSWORD_REQUEST = 'CHANGE_PASSWORD_REQUEST';
|
||||||
export const CHANGE_PASSWORD_SUCCESS = 'CHANGE_PASSWORD_SUCCESS';
|
export const CHANGE_PASSWORD_SUCCESS = 'CHANGE_PASSWORD_SUCCESS';
|
||||||
export const CHANGE_PASSWORD_FAIL = 'CHANGE_PASSWORD_FAIL';
|
export const CHANGE_PASSWORD_FAIL = 'CHANGE_PASSWORD_FAIL';
|
||||||
|
@ -183,6 +187,23 @@ export function changeEmail(email, password) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deactivateAccount(password) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: DEACTIVATE_ACCOUNT_REQUEST });
|
||||||
|
return api(getState).post('/api/pleroma/disable_account', {
|
||||||
|
password,
|
||||||
|
}).then(response => {
|
||||||
|
if (response.data.error) throw response.data.error; // This endpoint returns HTTP 200 even on failure
|
||||||
|
dispatch({ type: DEACTIVATE_ACCOUNT_SUCCESS, response });
|
||||||
|
dispatch({ type: AUTH_LOGGED_OUT });
|
||||||
|
dispatch(showAlert('Successfully logged out.', ''));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: DEACTIVATE_ACCOUNT_FAIL, error, skipAlert: true });
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function changePassword(oldPassword, newPassword, confirmation) {
|
export function changePassword(oldPassword, newPassword, confirmation) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: CHANGE_PASSWORD_REQUEST });
|
dispatch({ type: CHANGE_PASSWORD_REQUEST });
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
changePassword,
|
changePassword,
|
||||||
fetchOAuthTokens,
|
fetchOAuthTokens,
|
||||||
revokeOAuthToken,
|
revokeOAuthToken,
|
||||||
|
deactivateAccount,
|
||||||
} from 'soapbox/actions/auth';
|
} from 'soapbox/actions/auth';
|
||||||
import { showAlert } from 'soapbox/actions/alerts';
|
import { showAlert } from 'soapbox/actions/alerts';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue