Login.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="login-page">
  3. <!-- <auth-login />-->
  4. <login-component :redirect="true" />
  5. </div>
  6. </template>
  7. <script>
  8. // import AuthLogin from 'src/components/Auth.vue'
  9. import LoginComponent from 'src/components/Auth/LoginComponent.vue'
  10. export default {
  11. name: 'Login',
  12. // components: { AuthLogin },
  13. components: { LoginComponent },
  14. props: {
  15. redirect: {
  16. type: [Boolean],
  17. default: true
  18. }
  19. },
  20. computed: {
  21. isUserLogin () {
  22. return this.$store.getters['Auth/isUserLogin']
  23. }
  24. },
  25. mounted () {
  26. this.handleAuthenticatedUser()
  27. },
  28. methods: {
  29. redirectTo () {
  30. let redirectTo = this.$store.getters['Auth/redirectTo']
  31. if (this.redirect) {
  32. redirectTo = this.redirect
  33. }
  34. if (redirectTo === null || typeof redirectTo !== 'object') {
  35. redirectTo = { name: 'Public.Home' }
  36. }
  37. this.$router.push(redirectTo)
  38. this.$store.commit('Auth/updateRedirectTo', null)
  39. },
  40. handleAuthenticatedUser () {
  41. // ToDo: must check this if
  42. if (this.isUserLogin) {
  43. // this.$router.push({ name: 'Public.Home' })
  44. this.redirectTo()
  45. return
  46. }
  47. this.$store.dispatch('Auth/logOut', { clearRedirectTo: false })
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .login-page {
  54. height: 100vh;
  55. display: flex;
  56. justify-content: center;
  57. align-items: center;
  58. }
  59. </style>