Exemplo n.º 1
0
def tech_user(session):
    user = UserFactory.create(role=Roles.Tech,
                              resources=[Resources.FAMILY_READ.value])
    internal_user = InternalUser(login=user.username,
                                 email="*****@*****.**",
                                 password=hash_password('tech'),
                                 user=user)

    session.add(user)
    session.add(internal_user)
    session.commit()
    return user
Exemplo n.º 2
0
def regular_user(session):
    user = User(username='******', external_uuid=uuid4(), role=Roles.User)
    internal_user = InternalUser(login=user.username,
                                 email='*****@*****.**',
                                 password=hash_password('user_password'),
                                 user=user)

    session.add(user)
    session.add(internal_user)
    session.commit()

    return user
Exemplo n.º 3
0
def admin_user(session):
    user = User(username='******', external_uuid=uuid4(), role=Roles.Admin)

    internal_user = InternalUser(login=user.username,
                                 email='*****@*****.**',
                                 password=hash_password('admin'),
                                 user=user)

    session.add(user)
    session.add(internal_user)
    session.commit()

    return user
def create_internal_user(username: str,
                         email: str,
                         password: str,
                         role: Roles,
                         resources: Optional[List[str]] = None,
                         external_uuid: Optional[UUID] = None) -> User:
    user = User(username=username,
                active=True,
                external_uuid=external_uuid or uuid4(),
                resources=resources,
                role=role)

    internal_user = InternalUser(login=username,
                                 email=email,
                                 password=hash_password(password),
                                 user=user)
    db.session.add(user)
    db.session.add(internal_user)
    return user
def update_password(user: User, new_password: str):
    internal_user = user.internal_user
    if not internal_user:
        raise Exception(f"Internal user not found for {user.external_uuid}")

    internal_user.password = hash_password(new_password)