web/satellite: validation added on delete account popup (#3290)

This commit is contained in:
Vitalii Shpital 2019-10-17 13:19:21 +03:00 committed by GitHub
parent edf8318c0e
commit 25dbf46bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -38,7 +38,7 @@
</svg>
</div>
<div class='delete-account__form-container'>
<p class='delete-account__form-container__confirmation-text'>Are you sure you want to delete your account? If you do so, all your information, projects and API Keys will be deleted forever. (drop from the satellite)</p>
<p class='delete-account__form-container__confirmation-text'>Are you sure you want to delete your account? If you do so, all your information, projects and API Keys will be deleted forever (drop from the satellite).</p>
<HeaderedInput
label='Enter your password'
placeholder='Your Password'
@ -83,6 +83,7 @@ import { AuthApi } from '@/api/auth';
import { RouteConfig } from '@/router';
import { AuthToken } from '@/utils/authToken';
import { APP_STATE_ACTIONS, NOTIFICATION_ACTIONS } from '@/utils/constants/actionNames';
import { validatePassword } from '@/utils/validation';
@Component({
components: {
@ -99,6 +100,7 @@ export default class DeleteAccountPopup extends Vue {
public setPassword(value: string): void {
this.password = value;
this.passwordError = '';
}
public async onDeleteAccountClick(): Promise<void> {
@ -108,16 +110,24 @@ export default class DeleteAccountPopup extends Vue {
this.isLoading = true;
if (!validatePassword(this.password)) {
this.passwordError = 'Invalid password. Must be 6 or more characters';
this.isLoading = false;
return;
}
try {
await this.auth.delete(this.password);
this.$store.dispatch(NOTIFICATION_ACTIONS.SUCCESS, 'Account was successfully deleted');
await this.$store.dispatch(NOTIFICATION_ACTIONS.SUCCESS, 'Account was successfully deleted');
AuthToken.remove();
this.isLoading = false;
this.$router.push(RouteConfig.Login.path);
await this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_DEL_ACCOUNT);
await this.$router.push(RouteConfig.Login.path);
} catch (error) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, error.message);
await this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, error.message);
this.isLoading = false;
}
}

View File

@ -12,7 +12,7 @@
<EmptyState
v-if="!isProjectSelected"
main-title="Create your first project"
additional-text='<p>Please click the button <b>"New Project"</b> in the right corner</p>'
additional-text='<p>Please click the button <b>"New Project"</b> in the upper right corner</p>'
:image-source="emptyImage"
/>
</div>