2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-20 16:44:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class='delete-account-container'>
|
2019-01-09 15:40:21 +00:00
|
|
|
<div class='delete-account' id="deleteAccountPopup">
|
2018-12-20 16:44:42 +00:00
|
|
|
<div class='delete-account__info-panel-container'>
|
|
|
|
<h2 class='delete-account__info-panel-container__main-label-text'>Delete account</h2>
|
2019-10-23 13:26:39 +01:00
|
|
|
<DeleteAccountIcon/>
|
2018-12-20 16:44:42 +00:00
|
|
|
</div>
|
|
|
|
<div class='delete-account__form-container'>
|
2019-10-17 11:19:21 +01:00
|
|
|
<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>
|
2019-12-11 20:07:15 +00:00
|
|
|
<HeaderedInput
|
|
|
|
label='Enter your password'
|
2018-12-20 16:44:42 +00:00
|
|
|
placeholder='Your Password'
|
|
|
|
class='full-input'
|
|
|
|
width='100%'
|
2019-09-23 12:31:42 +01:00
|
|
|
is-password="true"
|
2018-12-20 16:44:42 +00:00
|
|
|
:error='passwordError'
|
2019-10-02 10:42:12 +01:00
|
|
|
@setData='setPassword'
|
|
|
|
/>
|
2018-12-20 16:44:42 +00:00
|
|
|
<div class='delete-account__form-container__button-container'>
|
2019-09-26 14:36:12 +01:00
|
|
|
<VButton
|
|
|
|
label='Cancel'
|
|
|
|
width='205px' height='48px'
|
|
|
|
:on-press='onCloseClick'
|
2020-09-15 13:44:23 +01:00
|
|
|
is-transparent="true"
|
2019-10-02 10:42:12 +01:00
|
|
|
/>
|
2019-09-26 14:36:12 +01:00
|
|
|
<VButton
|
|
|
|
label='Delete'
|
|
|
|
width='205px'
|
|
|
|
height='48px'
|
|
|
|
class='red'
|
2019-10-02 10:42:12 +01:00
|
|
|
:on-press='onDeleteAccountClick'
|
|
|
|
/>
|
2018-12-20 16:44:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-07-17 15:33:07 +01:00
|
|
|
<div class='delete-account__close-cross-container' @click='onCloseClick'>
|
2019-10-23 13:26:39 +01:00
|
|
|
<CloseCrossIcon/>
|
2018-12-20 16:44:42 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang='ts'>
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2019-08-14 19:11:18 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import HeaderedInput from '@/components/common/HeaderedInput.vue';
|
2019-09-26 14:36:12 +01:00
|
|
|
import VButton from '@/components/common/VButton.vue';
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-10-23 13:26:39 +01:00
|
|
|
import DeleteAccountIcon from '@/../static/images/account/deleteAccountPopup/deleteAccount.svg';
|
|
|
|
import CloseCrossIcon from '@/../static/images/common/closeCross.svg';
|
|
|
|
|
2019-10-29 14:24:16 +00:00
|
|
|
import { AuthHttpApi } from '@/api/auth';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { RouteConfig } from '@/router';
|
2019-10-28 17:33:06 +00:00
|
|
|
import { APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
|
2020-06-02 15:08:20 +01:00
|
|
|
import { Validator } from '@/utils/validation';
|
2019-12-12 15:18:47 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
2019-10-23 13:26:39 +01:00
|
|
|
DeleteAccountIcon,
|
|
|
|
CloseCrossIcon,
|
2019-09-09 11:33:39 +01:00
|
|
|
HeaderedInput,
|
2019-09-26 14:36:12 +01:00
|
|
|
VButton,
|
2019-09-13 15:58:18 +01:00
|
|
|
},
|
2019-09-09 11:33:39 +01:00
|
|
|
})
|
|
|
|
export default class DeleteAccountPopup extends Vue {
|
2021-08-02 19:17:49 +01:00
|
|
|
public passwordError = '';
|
|
|
|
private password = '';
|
|
|
|
private isLoading = false;
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-10-29 14:24:16 +00:00
|
|
|
private readonly auth: AuthHttpApi = new AuthHttpApi();
|
2018-12-20 16:44:42 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public setPassword(value: string): void {
|
|
|
|
this.password = value;
|
2019-10-17 11:19:21 +01:00
|
|
|
this.passwordError = '';
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Validates password and if it is correct tries to delete account, close popup and redirect to login page.
|
|
|
|
*/
|
2019-09-09 11:33:39 +01:00
|
|
|
public async onDeleteAccountClick(): Promise<void> {
|
|
|
|
if (this.isLoading) {
|
|
|
|
return;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
this.isLoading = true;
|
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
if (!Validator.password(this.password)) {
|
2019-10-17 11:19:21 +01:00
|
|
|
this.passwordError = 'Invalid password. Must be 6 or more characters';
|
|
|
|
this.isLoading = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
try {
|
|
|
|
await this.auth.delete(this.password);
|
2019-10-28 17:33:06 +00:00
|
|
|
await this.$notify.success('Account was successfully deleted');
|
2020-01-20 18:57:14 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
this.isLoading = false;
|
2019-10-17 11:19:21 +01:00
|
|
|
await this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_DEL_ACCOUNT);
|
|
|
|
await this.$router.push(RouteConfig.Login.path);
|
2019-09-09 11:33:39 +01:00
|
|
|
} catch (error) {
|
2019-10-28 17:33:06 +00:00
|
|
|
await this.$notify.error(error.message);
|
2019-09-09 11:33:39 +01:00
|
|
|
this.isLoading = false;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Closes popup.
|
|
|
|
*/
|
2019-09-09 11:33:39 +01:00
|
|
|
public onCloseClick(): void {
|
|
|
|
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_DEL_ACCOUNT);
|
|
|
|
}
|
|
|
|
}
|
2018-12-20 16:44:42 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang='scss'>
|
|
|
|
.delete-account-container {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
background-color: rgba(134, 134, 148, 0.4);
|
|
|
|
z-index: 1121;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_regular', sans-serif;
|
2018-12-20 16:44:42 +00:00
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2018-12-20 16:44:42 +00:00
|
|
|
.input-container.full-input {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2018-12-20 16:44:42 +00:00
|
|
|
.red {
|
2019-10-28 15:59:19 +00:00
|
|
|
background-color: #eb5757;
|
2018-12-20 16:44:42 +00:00
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2018-12-20 16:44:42 +00:00
|
|
|
.text {
|
2019-09-26 14:36:12 +01:00
|
|
|
margin: 0 !important;
|
2018-12-20 16:44:42 +00:00
|
|
|
font-size: 16px;
|
|
|
|
line-height: 25px;
|
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
|
2018-12-20 16:44:42 +00:00
|
|
|
.delete-account {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 845px;
|
2019-10-28 15:59:19 +00:00
|
|
|
background-color: #fff;
|
2018-12-20 16:44:42 +00:00
|
|
|
border-radius: 6px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: flex-start;
|
|
|
|
position: relative;
|
|
|
|
justify-content: center;
|
|
|
|
padding: 100px 100px 100px 80px;
|
|
|
|
|
|
|
|
&__info-panel-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
margin-right: 100px;
|
|
|
|
|
|
|
|
&__main-label-text {
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_bold', sans-serif;
|
2018-12-20 16:44:42 +00:00
|
|
|
font-size: 32px;
|
|
|
|
line-height: 39px;
|
2019-10-28 15:59:19 +00:00
|
|
|
color: #384b65;
|
2019-09-26 14:36:12 +01:00
|
|
|
margin: 0 0 60px 0;
|
2018-12-20 16:44:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__form-container {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 450px;
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__confirmation-text {
|
|
|
|
margin: 0 0 25px 0;
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_medium', sans-serif;
|
2018-12-20 16:44:42 +00:00
|
|
|
font-size: 16px;
|
|
|
|
line-height: 25px;
|
|
|
|
|
|
|
|
&:nth-child(2) {
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__button-container {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 30px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__close-cross-container {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
2019-01-30 13:18:07 +00:00
|
|
|
align-items: center;
|
2018-12-20 16:44:42 +00:00
|
|
|
position: absolute;
|
|
|
|
right: 30px;
|
|
|
|
top: 40px;
|
2019-01-30 13:18:07 +00:00
|
|
|
height: 24px;
|
|
|
|
width: 24px;
|
|
|
|
cursor: pointer;
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&:hover .close-cross-svg-path {
|
2019-10-28 15:59:19 +00:00
|
|
|
fill: #2683ff;
|
2018-12-20 16:44:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 720px) {
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2018-12-20 16:44:42 +00:00
|
|
|
.delete-account {
|
|
|
|
padding: 10px;
|
|
|
|
|
|
|
|
&__info-panel-container {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__form-container {
|
|
|
|
|
|
|
|
&__button-container {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|