async def sign_in( api_key: Optional[str] = Header(None), x_access_token: Optional[str] = Header(None), ): auth_service.verify_api_key(api_key) auth_service.verify_access_token(x_access_token) return {"message": "ok"}
async def unblock_user(uuid: int, db: Session = Depends(get_db), api_key: Optional[str] = Header(None)): auth_service.verify_api_key(api_key) user = RegisteredUserDAO.get_user(db, uuid) auth_service.unblock_user(user['email']) unblocked_user = RegisteredUserDAO.unblock_user(db, uuid) return unblocked_user
async def get_user_uuid( db: Session = Depends(get_db), api_key: Optional[str] = Header(None), x_access_token: Optional[str] = Header(None), ): auth_service.verify_api_key(api_key) user_data = auth_service.verify_access_token(x_access_token) user = RegisteredUserDAO.get_by_email(db, user_data["email"]) return user
async def delete_registered_user( uuid: int, db: Session = Depends(get_db), api_key: Optional[str] = Header(None), x_access_token: Optional[str] = Header(None), ): auth_service.verify_api_key(api_key) auth_service.verify_access_token(x_access_token) user = RegisteredUserDAO.delete_by_uuid(db, uuid) return user
async def add_registered_user( payload: RegisteredUserSchema, db: Session = Depends(get_db), api_key: Optional[str] = Header(None), x_access_token: Optional[str] = Header(None), ): auth_service.verify_api_key(api_key) auth_service.verify_access_token(x_access_token) user = RegisteredUserDAO.add_new_registered_user(db, payload, False) return user
async def add_registered_admin( payload: RegisteredUserSchema, db: Session = Depends(get_db), api_key: Optional[str] = Header(None), x_access_token: Optional[str] = Header(None), ): # Check API-KEY auth_service.verify_api_key(api_key) # Check that x-access-token is from a registered admin user_data = auth_service.verify_access_token(x_access_token) RegisteredUserDAO.get_admin_by_email(db, user_data["email"]) # Create the new admin user = RegisteredUserDAO.add_new_registered_user(db, payload, True) return user
async def get_all_admin_users(db: Session = Depends(get_db), api_key: Optional[str] = Header(None)): auth_service.verify_api_key(api_key) users = RegisteredUserDAO.get_all_admins(db) return {"amount": len(users), "users": users}