user disable/enable. disallow iot dev
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
22ecea44f6
commit
18ea7db1e7
@ -86,6 +86,7 @@ def read_user(user_id: int, db: Session = Depends(get_db)):
|
|||||||
raise HTTPException(status_code=404, detail="User not found")
|
raise HTTPException(status_code=404, detail="User not found")
|
||||||
return db_user
|
return db_user
|
||||||
|
|
||||||
|
# Add admin, disable user, activeate user
|
||||||
@app.post("/admin/users/{user_id}/allow/{iot_entity_id}", tags=['Admin'])
|
@app.post("/admin/users/{user_id}/allow/{iot_entity_id}", tags=['Admin'])
|
||||||
def allow_user_for_iot_entity(request: schemas.UserAllowForIotEntityRequest, db: Session = Depends(get_db)):
|
def allow_user_for_iot_entity(request: schemas.UserAllowForIotEntityRequest, db: Session = Depends(get_db)):
|
||||||
user = crud.get_user(db, request.user_id)
|
user = crud.get_user(db, request.user_id)
|
||||||
@ -102,6 +103,31 @@ def allow_user_for_iot_entity(request: schemas.UserAllowForIotEntityRequest, db:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@app.post("/admin/users/{user_id}/disallow/{iot_entity_id}", tags=['Admin'])
|
||||||
|
def allow_user_for_iot_entity(request: schemas.UserAllowForIotEntityRequest, db: Session = Depends(get_db)):
|
||||||
|
user = crud.get_user(db, request.user_id)
|
||||||
|
if not user:
|
||||||
|
raise HTTPException(status_code=404, detail="User not found")
|
||||||
|
|
||||||
|
iot_entity = crud.get_iot_entity(db, request.iot_entity_id)
|
||||||
|
if not iot_entity:
|
||||||
|
raise HTTPException(status_code=404, detail="Iot Entity not found")
|
||||||
|
|
||||||
|
#res = crud.create_user_link_to_iot(db, request.user_id, request.iot_entity_id)
|
||||||
|
# Implement remove link
|
||||||
|
if not res:
|
||||||
|
raise HTTPException(status_code=500, detail="Could not complete operation")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
@app.post("/admin/users/{user_id}/deactiveate", tags=['Admin'])
|
||||||
|
def deactiveate_user(user_id: int, db:Session = Depends(get_db)):
|
||||||
|
return
|
||||||
|
|
||||||
|
@app.post("/admin/users/{user_id}/activeate", tags=['Admin'])
|
||||||
|
def deactiveate_user(user_id: int, db:Session = Depends(get_db)):
|
||||||
|
return
|
||||||
|
|
||||||
@app.get("/users/acesslist/", response_model=List[schemas.IotEntity], tags=['Users'])
|
@app.get("/users/acesslist/", response_model=List[schemas.IotEntity], tags=['Users'])
|
||||||
def get_iot_access_list_for_user(db: Session = Depends(get_db), current_user: schemas.User = Depends(get_current_active_user)):
|
def get_iot_access_list_for_user(db: Session = Depends(get_db), current_user: schemas.User = Depends(get_current_active_user)):
|
||||||
user = crud.get_user_by_username(db, current_user.username)
|
user = crud.get_user_by_username(db, current_user.username)
|
||||||
|
Loading…
Reference in New Issue
Block a user