A
A
Anton Ivanov2019-10-01 13:53:02
API
Anton Ivanov, 2019-10-01 13:53:02

Why do api calls for the user account leave user_id on the way?

Hello.
Very often, when I look at what calls the SPA makes to the backend, I see request paths like this:
/:user_id/profile
/:user_id/support
and so on.
At the same time, authorization headers are transmitted in each request, by which the system determines the current user. That is (in my understanding) you can use view paths.
/profile
/support
Why do they do this, if we are talking about a user account, where the user should have access only to his "entities"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
developer007, 2019-10-01
@developer007

if you are an admin and edit a user, then naturally you must pass the user id to the back (for example, in a link).
if you are connected to this application with parents and the parent wants to see the profile of the child, then again you need to transfer the user.
in other cases, when you go to your profile and your ID is in this link, it makes no sense.
perhaps this is a code reuse mechanism, or the developers were too lazy to edit the copied project base, xs
there are many options why this is so.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question