Exemplo n.º 1
0
def create_user(user: schemas.security.UserCreate,
                db: Session = Depends(get_db)):
    db_user = User.by_email(user.email, db)
    if db_user:
        raise HTTPException(status_code=400, detail='Email already registered')
    # Overwrite user.password with a hashed version
    user.password = get_password_hash(user.password)
    return User.create(user, db)
Exemplo n.º 2
0
def get_user(db, email: str):
    user = User.by_email(email, db)
    return user