mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-26 08:42:03 +05:30
Allow account deletion from the user agreement page
This commit is contained in:
parent
7eeeb7cc61
commit
60e892d993
@ -78,7 +78,7 @@ export function authenticate(
|
||||
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
|
||||
// because user probably has made his choise now
|
||||
// this may happen, when user registers, logs in or uses account
|
||||
|
@ -7,6 +7,7 @@ import Body from './AcceptRulesBody';
|
||||
const messages = defineMessages({
|
||||
title: 'User Agreement',
|
||||
declineAndLogout: 'Decline and logout',
|
||||
deleteAccount: 'Delete account',
|
||||
});
|
||||
|
||||
export default factory({
|
||||
@ -17,7 +18,13 @@ export default factory({
|
||||
autoFocus: true,
|
||||
children: <Message key="accept" defaultMessage="Accept" />,
|
||||
},
|
||||
links: {
|
||||
label: messages.declineAndLogout,
|
||||
},
|
||||
links: [
|
||||
{
|
||||
label: messages.declineAndLogout,
|
||||
},
|
||||
{
|
||||
label: messages.deleteAccount,
|
||||
payload: { deleteAccount: true },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -83,7 +83,13 @@ describe('AcceptRulesState', () => {
|
||||
it('should 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 });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,13 @@ export default class AcceptRulesState extends AbstractState {
|
||||
.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');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user