Add ability to update user's data
- Password - Access token
This commit is contained in:
parent
b406a9a3c8
commit
85c07ed4f3
3 changed files with 41 additions and 1 deletions
21
app.py
21
app.py
|
|
@ -22,7 +22,6 @@ from models import (
|
|||
TableListDefinition,
|
||||
UserDefinition,
|
||||
)
|
||||
from secutils import hash_password
|
||||
from utils import (
|
||||
check_if_admin_access_token,
|
||||
parse_columns_from_definition,
|
||||
|
|
@ -136,6 +135,26 @@ async def createUser(
|
|||
return {"ok": True}
|
||||
|
||||
|
||||
@app.post("/api/updateUser")
|
||||
async def updateUser(
|
||||
user: UserDefinition,
|
||||
access_token: str | None = Header(default=None),
|
||||
):
|
||||
is_admin = check_if_admin_access_token(connector, access_token)
|
||||
if not is_admin:
|
||||
return {"error": "Not allowed"}
|
||||
|
||||
if not user.user_id or not user.password or not user.access_token:
|
||||
return {"error": "Malformed request"}
|
||||
|
||||
try:
|
||||
update_user(connector, user.user_id, user.password, user.access_token)
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@app.post("/items/{tableName}")
|
||||
async def items(
|
||||
tableName: str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue