manojkumar3692 / Vuejs-Authentication

84 stars 38 forks source link

how to prevent logged in user to come back on login page #2

Closed amitneg1 closed 7 years ago

amitneg1 commented 7 years ago

Logged in user should not come back on login page. For example Changing URL /admin => /login

manojkumar3692 commented 7 years ago

@amitneg1 You can use lifecycle events to perform this , we check with role ID when ever login page is triggered to login . I have pushed the code with the fix . loginAuth:function () { var app = this; const status = JSON.parse(window.localStorage.getItem('lbUser')); if(status === null || status === undefined) { app.$router.push('/login'); }else if (status.data.role_id === 'ADMIN') { app.$router.push('/admin'); }else { app.$router.push('/resident'); } }`

amitneg1 commented 7 years ago

Thanks Manoj!! Its working. Kudos