Logout.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div class="flex">
  3. <SmartItem
  4. svg="log-out"
  5. :label="`${$t('auth.logout')}`"
  6. :outline="outline"
  7. @click.native="
  8. () => {
  9. $emit('confirm-logout')
  10. confirmLogout = true
  11. }
  12. "
  13. />
  14. <SmartConfirmModal
  15. :show="confirmLogout"
  16. :title="`${$t('confirm.logout')}`"
  17. @hide-modal="confirmLogout = false"
  18. @resolve="logout"
  19. />
  20. </div>
  21. </template>
  22. <script lang="ts">
  23. import { defineComponent } from "@nuxtjs/composition-api"
  24. import { signOutUser } from "~/helpers/fb/auth"
  25. export default defineComponent({
  26. props: {
  27. outline: {
  28. type: Boolean,
  29. default: false,
  30. },
  31. },
  32. data() {
  33. return {
  34. confirmLogout: false,
  35. }
  36. },
  37. methods: {
  38. async logout() {
  39. try {
  40. await signOutUser()
  41. this.$toast.success(`${this.$t("auth.logged_out")}`, {
  42. icon: "vpn_key",
  43. })
  44. } catch (e) {
  45. console.error(e)
  46. this.$toast.error(`${this.$t("error.something_went_wrong")}`, {
  47. icon: "error_outline",
  48. })
  49. }
  50. },
  51. },
  52. })
  53. </script>