def add_user(): Utility.load_evironment() connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"]) user = AccountProcessor.account_setup( { "email": "*****@*****.**", "first_name": "Demo", "last_name": "User", "password": "******", "account": "integration", "bot": "integration" }, user="******") processor = MongoProcessor() processor.save_from_path("tests/testing_data/all", user['bot'], "testAdmin") AccountProcessor.account_setup( { "email": "*****@*****.**", "first_name": "Demo", "last_name": "User", "password": "******", "account": "integration2", "bot": "integration2" }, user="******")
def add_user(): Utility.load_evironment() connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"]) account = AccountProcessor.add_account("integration", "testAdmin") bot = AccountProcessor.add_bot("integration", account["_id"], "testAdmin") AccountProcessor.add_user( email="*****@*****.**", first_name="Demo", last_name="User", password="******", account=account["_id"], bot=bot["name"], user="******", ) account = AccountProcessor.add_account("integration2", "testAdmin") bot = AccountProcessor.add_bot("integration2", account["_id"], "testAdmin") AccountProcessor.add_user( email="*****@*****.**", first_name="Demo", last_name="User", password="******", account=account["_id"], bot=bot["name"], user="******", )
def init_connection(): Utility.load_evironment() connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"])
from datetime import datetime, timedelta from typing import Text import jwt from fastapi import Depends, HTTPException, status, Request from jwt import PyJWTError from bot_trainer.utils import Utility from .models import * from .processor import AccountProcessor Utility.load_evironment() class Authentication: SECRET_KEY = Utility.environment["SECRET_KEY"] ALGORITHM = Utility.environment["ALGORITHM"] ACCESS_TOKEN_EXPIRE_MINUTES = Utility.environment[ "ACCESS_TOKEN_EXPIRE_MINUTES"] async def get_current_user(self, request: Request, token: str = Depends(Utility.oauth2_scheme)): credentials_exception = HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Could not validate credentials", headers={"WWW-Authenticate": "Bearer"}, ) try: payload = jwt.decode(token, self.SECRET_KEY,
def setup(): Utility.load_evironment() connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"])