Exemple #1
0
def accept_user_referral(user_email: str, reference_email: str) -> bool:
    with session_scope() as session:
        requester = User.get_by_email(session, user_email)
        reference = User.get_by_email(session, reference_email)
        if requester is None or reference is None:
            return False
        UserReferral()
Exemple #2
0
def login(email: str, password: str) -> 'UserData':
    with session_scope() as session:
        if User.verify_credentials(session, email, password):
            user = User.get_by_email(session, email)
            if not user.active:
                verification = UserVerification.get_by_user(session, user.id)
                threshold = int(get_property('user.threshold'))
                if not verification and threshold > 0:
                    verification = UserVerification.add(session,
                                                        user_id=user.id)
                    send_verification_email(to=email, code=verification.code)
                    set_property('user.threshold', threshold - 1)
            user.login_count += 1
            return UserData(user)
    return None
Exemple #3
0
def get_user_by_email(email: str) -> Optional[UserData]:
    with session_scope() as session:
        user = User.get_by_email(session, email)
        return None if not user else UserData(user)