1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Some more improvements, but i'm not satisfied yet

This commit is contained in:
Steffo 2020-03-09 19:13:32 +01:00
parent 68ff79f301
commit eacbb963a5
7 changed files with 17 additions and 10 deletions

View file

@ -18,6 +18,8 @@ class ApiTokenCreateStar(ApiStar):
tags = ["token"]
requires_auth = True
async def api(self, data: ApiData) -> ru.JSON:
user = await data.user()
try:

View file

@ -9,6 +9,8 @@ class ApiTokenInfoStar(ApiStar):
tags = ["token"]
requires_auth = True
async def api(self, data: ApiData) -> ru.JSON:
token = await data.token()
return token.json()

View file

@ -9,15 +9,17 @@ from ..tables.tokens import Token
class ApiTokenPasswdStar(ApiStar):
path = "/api/token/passwd/v1"
methods = ["POST"]
methods = ["PUT"]
summary = "Change Royalnet password for an user."
tags = ["token"]
parameters = {
"new_password": "The password you want to set."
}
tags = ["token"]
requires_auth = True
async def api(self, data: ApiData) -> ru.JSON:
TokenT = self.alchemy.get(Token)

View file

@ -8,12 +8,12 @@ class ApiUserFindStar(ApiStar):
summary = "Find a Royalnet user by one of their aliases."
tags = ["user"]
parameters = {
"alias": "One of the aliases of the user to get."
}
tags = ["user"]
async def api(self, data: ApiData) -> dict:
user = await Alias.find_user(self.alchemy, data.session, data["alias"])
if user is None:

View file

@ -28,16 +28,13 @@ class DocsStar(PageStar):
"paths": paths,
"components": {
"securitySchemes": {
"LoginTokenAuth": {
"RoyalnetLoginToken": {
"type": "apiKey",
"in": "query",
"name": "token",
}
}
},
"security": [
{"LoginTokenAuth": []}
]
}
})
return HTMLResponse(

View file

@ -19,6 +19,8 @@ class ApiStar(PageStar, ABC):
tags: List[str] = []
requires_auth: bool = False
async def page(self, request: Request) -> JSONResponse:
if request.query_params:
data = request.query_params
@ -74,4 +76,6 @@ class ApiStar(PageStar, ABC):
"type": "string"
} for parameter in cls.parameters]
}
if cls.requires_auth:
result[method.lower()]["security"] = [{"RoyalnetLoginToken": ["logged_in"]}]
return result

View file

@ -1 +1 @@
semantic = "5.6.1"
semantic = "5.6.2"