Add logout button

This commit is contained in:
2022-11-06 18:54:10 +01:00
parent 1ed0790804
commit c2cc1f4c17

View File

@@ -2,7 +2,7 @@
<v-app :style="{ background: $vuetify.theme.themes[theme].background }"> <v-app :style="{ background: $vuetify.theme.themes[theme].background }">
<v-main> <v-main>
<v-container fill-height> <v-container fill-height>
<v-card max-width="500px" class="mx-auto"> <v-card max-width="500" class="mx-auto">
<v-card-title> <v-card-title>
Verifiziere deine E-Mail-Adresse! Verifiziere deine E-Mail-Adresse!
</v-card-title> </v-card-title>
@@ -13,6 +13,7 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn text color="primary" @click="logout">Logout</v-btn>
<v-btn depressed color="primary" :loading="loading" @click="sendVerificationEmail">E-Mail erneut senden</v-btn> <v-btn depressed color="primary" :loading="loading" @click="sendVerificationEmail">E-Mail erneut senden</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
@@ -24,7 +25,7 @@
</template> </template>
<script> <script>
import { sendEmailVerification } from 'firebase/auth' import { sendEmailVerification, signOut } from 'firebase/auth'
export default { export default {
name: 'UnverifiedLayout', name: 'UnverifiedLayout',
@@ -47,15 +48,28 @@ export default {
this.loading = true this.loading = true
sendEmailVerification(this.$auth.currentUser) sendEmailVerification(this.$auth.currentUser)
.then(() => { .then((empty) => {
// Email verification sent! // Email verification sent!
this.loading = false
this.$toast({ this.$toast({
content: 'Erfolg! Folge dem Link in der E-Mail, die wir dir gerade geschickt haben, um deine Registrierung abzuschließen!', content: 'Erfolg! Folge dem Link in der E-Mail, die wir dir gerade geschickt haben, um deine Registrierung abzuschließen!',
color: 'success', color: 'success',
timeout: -1 timeout: -1
}) })
}) })
.catch((error) => {
this.$toast({ content: error, color: 'error' })
})
.then(() => { this.loading = false })
},
logout () {
signOut(this.$auth).then(() => {
// Sign-out successful
// The authentication state observer will redirect the user to the main page (dashboard),
// see pages/index.vue
}).catch((error) => {
// An error happened.
this.$toast({ content: error, color: 'error' })
})
} }
} }
} }