예제 #1
0
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="******")
예제 #2
0
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="******",
    )
예제 #3
0
def init_connection():
    Utility.load_evironment()
    connect(Utility.environment["mongo_db"], host=Utility.environment["mongo_url"])
예제 #4
0
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,
예제 #5
0
def setup():
    Utility.load_evironment()
    connect(Utility.environment["mongo_db"],
            host=Utility.environment["mongo_url"])