k4cg / matomat-service

Matomat as a Service (MaaS)
MIT License
5 stars 2 forks source link

API-Login Question #1

Closed noqqe closed 6 years ago

noqqe commented 6 years ago

This "issue" is a mixture of me not being sure how stuff works and a design question.

When I'm authenticating myself I do a

POST /auth/login username=foo password=bar

Once I have my token back, Im using the token to auth against my next action, in this case adding credits.

POST /users/{userId}/credits/add credits=1500

How do I get this userId? I could handle this on the clientside by listing all users with GET /users and then pattern match the username i was authentication myself intially but somehow it doesnt feel right. Is this how its supposed to work? Or would it be more clean to if the AuthSuccess Schema also responds with my userid (besides the token) ?

Any help appreciated :)

winterMate commented 6 years ago

lol EXCELLENT catch. Yes this is a bug. Lets decide that the login call also returns the userid explicitly.

winterMate commented 6 years ago

With the latest commit, the user information of the current user is returned on successfull /auth/login.