LynxMasters / lynxmasters-ui

0 stars 0 forks source link

Unauthenticated/Authenticated Redirects #55

Closed ianarsenault closed 6 years ago

ianarsenault commented 6 years ago

If a user attempts to access a page without being authenticated/have an existing jwt the page should automatically redirect them back to home or login.

Also if a user access lynxmasters.com and has an existing valid token, they should automatically be redirected to their profile page.

If a user accesses / "landing" and has an existing token, they should be redirected to profile view

created () {
  this.checkAuthentication()
},
updated () {
  this.checkAuthentication()
},
methods: {
  checkAuthentication () {
    if (localStorage.token is valid) {
      this.$router.replace(this.$route.query.redirect || '/profile')
    }
  },
  // ...
}