Auth.js 643 B

12345678910111213141516171819202122232425262728
  1. import { User } from 'src/models/User.js'
  2. import { APIGateway } from 'src/api/APIGateway.js'
  3. const mixinAuth = {
  4. data () {
  5. return {
  6. user: new User(),
  7. isUserLogin: false
  8. }
  9. },
  10. mounted () {
  11. this.loadAuthData()
  12. },
  13. methods: {
  14. loadAuthData () { // prevent Hydration node mismatch
  15. this.user = this.$store.getters['Auth/user']
  16. this.isUserLogin = this.$store.getters['Auth/isUserLogin']
  17. },
  18. async getUserData () {
  19. APIGateway.user.showUser()
  20. .then((response) => {
  21. this.$store.commit('Auth/updateUser', response.data.data)
  22. })
  23. }
  24. }
  25. }
  26. export default mixinAuth