R
R
real22102019-02-26 15:57:35
Vue.js
real2210, 2019-02-26 15:57:35

How to protect the route from unwanted input?

In my project, each user has his own role, how can I redirect the user from routes that he should not get to in any way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kuznetsov, 2019-02-26
@dima9595

Middleware (if Nuxt) or Meta-data

V
vimirtv, 2019-02-28
@vimirtv

I implemented it like this.
JWT token comes from the server. With every transition. Am I checking if the token is valid? Navigation hooks
are used for this .

router.beforeEach((to, from, next) => {
//......
}

To protect against transitions, as already mentioned above, I used Meta-data where I indicated which roles were allowed to transition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question