Allow account deletion from the user agreement page

This commit is contained in:
ErickSkrauch 2020-08-01 01:40:11 +03:00
parent 7eeeb7cc61
commit 60e892d993
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
4 changed files with 25 additions and 6 deletions

View File

@ -78,7 +78,7 @@ export function authenticate(
sessionStorage.setItem(`stranger${newAccount.id}`, '1'); sessionStorage.setItem(`stranger${newAccount.id}`, '1');
} }
if (auth && auth.oauth && auth.oauth.clientId) { if (auth?.oauth?.clientId) {
// if we authenticating during oauth, we disable account chooser // if we authenticating during oauth, we disable account chooser
// because user probably has made his choise now // because user probably has made his choise now
// this may happen, when user registers, logs in or uses account // this may happen, when user registers, logs in or uses account

View File

@ -7,6 +7,7 @@ import Body from './AcceptRulesBody';
const messages = defineMessages({ const messages = defineMessages({
title: 'User Agreement', title: 'User Agreement',
declineAndLogout: 'Decline and logout', declineAndLogout: 'Decline and logout',
deleteAccount: 'Delete account',
}); });
export default factory({ export default factory({
@ -17,7 +18,13 @@ export default factory({
autoFocus: true, autoFocus: true,
children: <Message key="accept" defaultMessage="Accept" />, children: <Message key="accept" defaultMessage="Accept" />,
}, },
links: { links: [
{
label: messages.declineAndLogout, label: messages.declineAndLogout,
}, },
{
label: messages.deleteAccount,
payload: { deleteAccount: true },
},
],
}); });

View File

@ -83,7 +83,13 @@ describe('AcceptRulesState', () => {
it('should logout', () => { it('should logout', () => {
expectRun(mock, 'logout'); expectRun(mock, 'logout');
state.reject(context); state.reject(context, {});
});
it('should navigate to the account deletion page', () => {
expectNavigate(mock, '/profile/delete');
state.reject(context, { deleteAccount: true });
}); });
}); });
}); });

View File

@ -22,7 +22,13 @@ export default class AcceptRulesState extends AbstractState {
.catch((err = {}) => err.errors || logger.warn('Error accepting rules', err)); .catch((err = {}) => err.errors || logger.warn('Error accepting rules', err));
} }
reject(context: AuthContext): void { reject(context: AuthContext, payload: Record<string, any>): void {
if (payload.deleteAccount) {
context.navigate('/profile/delete');
return;
}
context.run('logout'); context.run('logout');
} }
} }