Merge branch 'delete-account-fixes' into 'master'
Fix deleting own account See merge request framasoft/mobilizon!1050
This commit is contained in:
commit
f3bb1f8976
@ -54,7 +54,7 @@ $success-invert: findColorInvert($success);
|
|||||||
$info: #36bcd4;
|
$info: #36bcd4;
|
||||||
$info-invert: findColorInvert($info);
|
$info-invert: findColorInvert($info);
|
||||||
$danger: #ff2e54;
|
$danger: #ff2e54;
|
||||||
$danger-invert: findColorInvert($danger);
|
$danger-invert: #000;
|
||||||
$link: $primary;
|
$link: $primary;
|
||||||
$link-invert: $primary-invert;
|
$link-invert: $primary-invert;
|
||||||
$text: $violet-1;
|
$text: $violet-1;
|
||||||
|
@ -51,20 +51,22 @@
|
|||||||
class="form"
|
class="form"
|
||||||
v-if="canChangeEmail"
|
v-if="canChangeEmail"
|
||||||
>
|
>
|
||||||
<b-field :label="$t('New email')">
|
<b-field :label="$t('New email')" label-for="account-email">
|
||||||
<b-input
|
<b-input
|
||||||
aria-required="true"
|
aria-required="true"
|
||||||
required
|
required
|
||||||
type="email"
|
type="email"
|
||||||
|
id="account-email"
|
||||||
v-model="newEmail"
|
v-model="newEmail"
|
||||||
/>
|
/>
|
||||||
</b-field>
|
</b-field>
|
||||||
<p class="help">{{ $t("You'll receive a confirmation email.") }}</p>
|
<p class="help">{{ $t("You'll receive a confirmation email.") }}</p>
|
||||||
<b-field :label="$t('Password')">
|
<b-field :label="$t('Password')" label-for="account-password">
|
||||||
<b-input
|
<b-input
|
||||||
aria-required="true"
|
aria-required="true"
|
||||||
required
|
required
|
||||||
type="password"
|
type="password"
|
||||||
|
id="account-password"
|
||||||
password-reveal
|
password-reveal
|
||||||
minlength="6"
|
minlength="6"
|
||||||
v-model="passwordForEmailChange"
|
v-model="passwordForEmailChange"
|
||||||
@ -105,23 +107,25 @@
|
|||||||
class="form"
|
class="form"
|
||||||
v-if="canChangePassword"
|
v-if="canChangePassword"
|
||||||
>
|
>
|
||||||
<b-field :label="$t('Old password')">
|
<b-field :label="$t('Old password')" label-for="account-old-password">
|
||||||
<b-input
|
<b-input
|
||||||
aria-required="true"
|
aria-required="true"
|
||||||
required
|
required
|
||||||
type="password"
|
type="password"
|
||||||
password-reveal
|
password-reveal
|
||||||
minlength="6"
|
minlength="6"
|
||||||
|
id="account-old-password"
|
||||||
v-model="oldPassword"
|
v-model="oldPassword"
|
||||||
/>
|
/>
|
||||||
</b-field>
|
</b-field>
|
||||||
<b-field :label="$t('New password')">
|
<b-field :label="$t('New password')" label-for="account-new-password">
|
||||||
<b-input
|
<b-input
|
||||||
aria-required="true"
|
aria-required="true"
|
||||||
required
|
required
|
||||||
type="password"
|
type="password"
|
||||||
password-reveal
|
password-reveal
|
||||||
minlength="6"
|
minlength="6"
|
||||||
|
id="account-new-password"
|
||||||
v-model="newPassword"
|
v-model="newPassword"
|
||||||
/>
|
/>
|
||||||
</b-field>
|
</b-field>
|
||||||
@ -180,14 +184,29 @@
|
|||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
<form @submit.prevent="deleteAccount">
|
<form @submit.prevent="deleteAccount">
|
||||||
<b-field v-if="hasUserGotAPassword">
|
<b-field
|
||||||
|
:type="deleteAccountPasswordFieldType"
|
||||||
|
v-if="hasUserGotAPassword"
|
||||||
|
label-for="account-deletion-password"
|
||||||
|
>
|
||||||
<b-input
|
<b-input
|
||||||
type="password"
|
type="password"
|
||||||
v-model="passwordForAccountDeletion"
|
v-model="passwordForAccountDeletion"
|
||||||
password-reveal
|
password-reveal
|
||||||
|
id="account-deletion-password"
|
||||||
|
:aria-label="$t('Password')"
|
||||||
icon="lock"
|
icon="lock"
|
||||||
:placeholder="$t('Password')"
|
:placeholder="$t('Password')"
|
||||||
/>
|
/>
|
||||||
|
<template #message>
|
||||||
|
<b-message
|
||||||
|
type="is-danger"
|
||||||
|
v-for="message in deletePasswordErrors"
|
||||||
|
:key="message"
|
||||||
|
>
|
||||||
|
{{ message }}
|
||||||
|
</b-message>
|
||||||
|
</template>
|
||||||
</b-field>
|
</b-field>
|
||||||
<b-button
|
<b-button
|
||||||
native-type="submit"
|
native-type="submit"
|
||||||
@ -217,6 +236,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { IAuthProvider } from "@/types/enums";
|
import { IAuthProvider } from "@/types/enums";
|
||||||
|
import { GraphQLError } from "graphql/error/GraphQLError";
|
||||||
import { Component, Vue, Ref } from "vue-property-decorator";
|
import { Component, Vue, Ref } from "vue-property-decorator";
|
||||||
import { Route } from "vue-router";
|
import { Route } from "vue-router";
|
||||||
import {
|
import {
|
||||||
@ -256,6 +276,8 @@ export default class AccountSettings extends Vue {
|
|||||||
|
|
||||||
changePasswordErrors: string[] = [];
|
changePasswordErrors: string[] = [];
|
||||||
|
|
||||||
|
deletePasswordErrors: string[] = [];
|
||||||
|
|
||||||
isDeleteAccountModalActive = false;
|
isDeleteAccountModalActive = false;
|
||||||
|
|
||||||
passwordForAccountDeletion = "";
|
passwordForAccountDeletion = "";
|
||||||
@ -313,6 +335,8 @@ export default class AccountSettings extends Vue {
|
|||||||
|
|
||||||
async deleteAccount(): Promise<Route | void> {
|
async deleteAccount(): Promise<Route | void> {
|
||||||
try {
|
try {
|
||||||
|
this.deletePasswordErrors = [];
|
||||||
|
console.debug("Asking to delete account...");
|
||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: DELETE_ACCOUNT,
|
mutation: DELETE_ACCOUNT,
|
||||||
variables: {
|
variables: {
|
||||||
@ -321,7 +345,8 @@ export default class AccountSettings extends Vue {
|
|||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await logout(this.$apollo.provider.defaultClient);
|
console.debug("Deleted account, logging out client...");
|
||||||
|
await logout(this.$apollo.provider.defaultClient, false);
|
||||||
this.$buefy.notification.open({
|
this.$buefy.notification.open({
|
||||||
message: this.$t(
|
message: this.$t(
|
||||||
"Your account has been successfully deleted"
|
"Your account has been successfully deleted"
|
||||||
@ -333,7 +358,9 @@ export default class AccountSettings extends Vue {
|
|||||||
|
|
||||||
return await this.$router.push({ name: RouteName.HOME });
|
return await this.$router.push({ name: RouteName.HOME });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.handleErrors("delete", err);
|
this.deletePasswordErrors = err.graphQLErrors.map(
|
||||||
|
({ message }: GraphQLError) => message
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,6 +388,10 @@ export default class AccountSettings extends Vue {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get deleteAccountPasswordFieldType(): string | null {
|
||||||
|
return this.deletePasswordErrors.length > 0 ? "is-danger" : null;
|
||||||
|
}
|
||||||
|
|
||||||
private handleErrors(type: string, err: any) {
|
private handleErrors(type: string, err: any) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
||||||
@ -382,6 +413,12 @@ export default class AccountSettings extends Vue {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.modal.is-active.is-full-screen {
|
||||||
|
.help.is-danger {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.cancel-button {
|
.cancel-button {
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user