L
L
Larisa .•º2017-10-09 22:09:09
Vue.js
Larisa .•º, 2017-10-09 22:09:09

How to control interface on frontend from user type?

There is a site that can have several types of users (administrator, manager, etc.) and, depending on the type of authorized user, different elements in the interface should be available to him.
If with the issuance of information via the API it is quite simple - on the server we check the user type and if it is not the one that is needed, then we send an error. But what if, for example, we have a component with an article and if the user type is admin, then the "delete" button will be available, but if the manager is not?
Store user type in redax store? not an option, you can change it through the console - a hole.
Before rendering this component, make a request to the server with the current cookies and get the user type, and after receiving the response, render the component?
The server is on Django, but I think that it doesn’t make much difference what backing to use here.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Kulakov, 2017-10-09
@kulakoff Vue.js

Store user in Vuex.
Hide the button depending on the type of user.
Delete requests will still happen via api and must have a token or session in the cookie. Even if the user can show the button in the interface, the api will still not allow the request to be executed without a token.

A
Artem0071, 2017-10-09
@Artem0071

well, let the user change the type, just check his type on the server and ban objectionable encoders

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question