mirror of
https://github.com/romancm/gamebrary
synced 2024-12-24 01:53:07 +00:00
improved delete account
This commit is contained in:
parent
3964d82442
commit
9aa83a7066
2 changed files with 88 additions and 79 deletions
|
@ -5,18 +5,36 @@
|
||||||
<b-modal
|
<b-modal
|
||||||
id="account-settings"
|
id="account-settings"
|
||||||
hide-footer
|
hide-footer
|
||||||
body-class="p-0"
|
|
||||||
title="Delete account"
|
title="Delete account"
|
||||||
>
|
>
|
||||||
<!-- TODO: delete Boards -->
|
<b-alert show variant="success" v-if="deleting && progress === 5">
|
||||||
<!-- TODO: delete Files -->
|
Account deleted
|
||||||
<!-- TODO: delete Tags -->
|
</b-alert>
|
||||||
<!-- TODO: delete Notes -->
|
|
||||||
<!-- TODO: delete Progresses -->
|
|
||||||
<!-- TODO: delete Settings -->
|
|
||||||
<!-- TODO: delete Tags -->
|
|
||||||
|
|
||||||
<b-button variant="danger" @click="promptDeleteAccount">
|
<template v-else-if="deleting">
|
||||||
|
{{ message }}
|
||||||
|
<b-progress :value="progress" :max="5" class="mb-3" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div v-else>
|
||||||
|
The following database entries will be deleted FOREVER.
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>User</li>
|
||||||
|
<li>Tags</li>
|
||||||
|
<li>Notes</li>
|
||||||
|
<li>Game Progresses</li>
|
||||||
|
<li>Settings</li>
|
||||||
|
<li>Boards</li>
|
||||||
|
<!-- <li>Wallpapers </li> -->
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<b-button
|
||||||
|
variant="danger"
|
||||||
|
@click="promptDeleteAccount"
|
||||||
|
:disabled="deleting"
|
||||||
|
>
|
||||||
Delete Account
|
Delete Account
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
|
@ -25,10 +43,27 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
import firebase from 'firebase/app';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
progress: 0,
|
||||||
|
deleting: false,
|
||||||
|
message: 'test',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['user']),
|
...mapState([
|
||||||
|
'user',
|
||||||
|
'tags',
|
||||||
|
'notes',
|
||||||
|
'progresses',
|
||||||
|
'settings',
|
||||||
|
'boards',
|
||||||
|
'wallpapers',
|
||||||
|
]),
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -45,31 +80,46 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteAccount() {
|
async deleteAccount() {
|
||||||
// const db = firebase.firestore();
|
this.deleting = true;
|
||||||
//
|
|
||||||
// // TODO: Add progress bar, delete tags, files, etc...
|
const db = firebase.firestore();
|
||||||
// // TODO: move to actions
|
const user = firebase.auth().currentUser;
|
||||||
// db.collection('settings').doc(this.user.uid).delete()
|
|
||||||
// .then(() => {
|
this.message = 'Deleting tags';
|
||||||
// // TODO: move to actions
|
await db.collection('tags').doc(this.user.uid).delete();
|
||||||
// db.collection('lists').doc(this.user.uid).delete()
|
this.progress = this.progress + 1;
|
||||||
// .then(() => {
|
|
||||||
// this.$bvToast.toast('Account deleted', { title: 'Success', variant: 'success' });
|
this.message = 'Deleting notes';
|
||||||
// const exitUrl = process.env.NODE_ENV === 'development'
|
await db.collection('notes').doc(this.user.uid).delete();
|
||||||
// ? 'http://localhost:3000'
|
this.progress = this.progress + 1;
|
||||||
// : 'https://gamebrary.com';
|
|
||||||
//
|
this.message = 'Deleting game progresses';
|
||||||
// this.$store.commit('CLEAR_SESSION');
|
await db.collection('progresses').doc(this.user.uid).delete();
|
||||||
// window.location.href = exitUrl;
|
this.progress = this.progress + 1;
|
||||||
// })
|
|
||||||
// .catch(() => {
|
this.message = 'Deleting settings';
|
||||||
// this.$store.commit('SET_SESSION_EXPIRED', true);
|
await db.collection('settings').doc(this.user.uid).delete();
|
||||||
// });
|
this.progress = this.progress + 1;
|
||||||
// })
|
|
||||||
// .catch(() => {
|
this.message = 'Deleting boards';
|
||||||
// this.$store.commit('SET_SESSION_EXPIRED', true);
|
await db.collection('boards').doc(this.user.uid).delete();
|
||||||
// });
|
this.progress = this.progress + 1;
|
||||||
|
|
||||||
|
user.delete().then(() => {
|
||||||
|
this.$bvToast.toast('Account deleted', { title: 'Success', variant: 'success' });
|
||||||
|
|
||||||
|
const exitUrl = process.env.NODE_ENV === 'development'
|
||||||
|
? 'http://localhost:3000'
|
||||||
|
: 'https://gamebrary.com';
|
||||||
|
|
||||||
|
window.location.href = exitUrl;
|
||||||
|
|
||||||
|
this.$store.commit('CLEAR_SESSION');
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$store.commit('SET_SESSION_EXPIRED', true);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,9 +51,7 @@
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
|
|
||||||
<b-list-group-item>
|
<b-list-group-item>
|
||||||
<b-button variant="danger" @click="promptDeleteAccount">
|
<delete-account />
|
||||||
Delete Account
|
|
||||||
</b-button>
|
|
||||||
</b-list-group-item>
|
</b-list-group-item>
|
||||||
|
|
||||||
<b-list-group-item>
|
<b-list-group-item>
|
||||||
|
@ -65,14 +63,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import firebase from 'firebase/app';
|
|
||||||
import SignOut from '@/components/Settings/SignOut';
|
import SignOut from '@/components/Settings/SignOut';
|
||||||
|
import DeleteAccount from '@/components/Settings/DeleteAccount';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
SignOut,
|
SignOut,
|
||||||
|
DeleteAccount,
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -83,46 +82,6 @@ export default {
|
||||||
formatDate(date) {
|
formatDate(date) {
|
||||||
return moment(date).format('LL');
|
return moment(date).format('LL');
|
||||||
},
|
},
|
||||||
|
|
||||||
promptDeleteAccount() {
|
|
||||||
this.$bvModal.msgBoxConfirm('All your data will be removed', {
|
|
||||||
title: 'Are you sure you want to delete your account?',
|
|
||||||
okVariant: 'danger',
|
|
||||||
okTitle: 'Yes, delete account! Hahaha!',
|
|
||||||
})
|
|
||||||
.then((value) => {
|
|
||||||
if (value) {
|
|
||||||
this.deleteAccount();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteAccount() {
|
|
||||||
const db = firebase.firestore();
|
|
||||||
|
|
||||||
// TODO: Add progress bar, delete tags, files, etc...
|
|
||||||
// TODO: move to actions
|
|
||||||
db.collection('settings').doc(this.user.uid).delete()
|
|
||||||
.then(() => {
|
|
||||||
// TODO: move to actions
|
|
||||||
db.collection('lists').doc(this.user.uid).delete()
|
|
||||||
.then(() => {
|
|
||||||
this.$bvToast.toast('Account deleted', { title: 'Success', variant: 'success' });
|
|
||||||
const exitUrl = process.env.NODE_ENV === 'development'
|
|
||||||
? 'http://localhost:3000'
|
|
||||||
: 'https://gamebrary.com';
|
|
||||||
|
|
||||||
this.$store.commit('CLEAR_SESSION');
|
|
||||||
window.location.href = exitUrl;
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$store.commit('SET_SESSION_EXPIRED', true);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$store.commit('SET_SESSION_EXPIRED', true);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue