mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
add endpoint for get user info by token (/me)
This commit is contained in:
@@ -22,4 +22,4 @@ class LoginSchema(ModelSchema):
|
||||
class UserSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["email", "username"]
|
||||
fields = ["id", "email", "username"]
|
||||
|
||||
@@ -54,6 +54,16 @@ def sign_in(request, data: LoginSchema):
|
||||
return status.OK, TokenSchema(token=token)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/me",
|
||||
response={
|
||||
status.OK: UserSchema,
|
||||
status.UNAUTHORIZED: ForbiddenError,
|
||||
},
|
||||
)
|
||||
def get_me(request):
|
||||
return 200, request.auth
|
||||
|
||||
@router.get(
|
||||
path="/user/{user_id}",
|
||||
response={
|
||||
|
||||
Reference in New Issue
Block a user