from sqlalchemy.orm import Session

# Session is used as Datatype Validator
from schemas.users import UserCreate
from db.models.users import User
from core.hashing import Hasher


# Define a function to Create new User
# user has datatype of UserCreate class and db has datatype of Session
def create_new_user(user: UserCreate, db: Session):
    user = User(username=user.username,
                email=user.email,
                hashed_password=Hasher.get_password_hash(user.password),
                is_active=True,
                is_superuser=False
                )
    # Add user to DB
    db.add(user)
    db.commit()
    db.refresh(user)
    return user

3c6ef556d01132daa90f8c6f14de39cdcaec8637
<mask token>

<mask token>


def create_new_user(user: UserCreate, db: Session):
    user = User(username=user.username, email=user.email, hashed_password=
        Hasher.get_password_hash(user.password), is_active=True,
        is_superuser=False)
    db.add(user)
    db.commit()
    db.refresh(user)
    return user

from sqlalchemy.orm import Session
from schemas.users import UserCreate
from db.models.users import User
from core.hashing import Hasher


def create_new_user(user: UserCreate, db: Session):
    user = User(username=user.username, email=user.email, hashed_password=
        Hasher.get_password_hash(user.password), is_active=True,
        is_superuser=False)
    db.add(user)
    db.commit()
    db.refresh(user)
    return user

from sqlalchemy.orm import Session

# Session is used as Datatype Validator
from schemas.users import UserCreate
from db.models.users import User
from core.hashing import Hasher


# Define a function to Create new User
# user has datatype of UserCreate class and db has datatype of Session
def create_new_user(user: UserCreate, db: Session):
    user = User(username=user.username,
                email=user.email,
                hashed_password=Hasher.get_password_hash(user.password),
                is_active=True,
                is_superuser=False
                )
    # Add user to DB
    db.add(user)
    db.commit()
    db.refresh(user)
    return user
