Ejemplo n.º 1
0
 def is_login_valid(email, password):
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistsError("Your user does not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError("Your password is wrong")
     return True
Ejemplo n.º 2
0
    def login_is_valid(username, password):
        user_data = Database.find_one("users", {"username": username})
        if user_data is None:
            raise UserErrors.UserNotExistError("The username doesn't exist")

        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Incorrect password")

        return True
Ejemplo n.º 3
0
 def is_login_valid(email, password):
     """This method verify that email and password is valid or not
     password is a ha512 hashed password
     will if valid else false otherwise"""
     user_data = Database.find_one(UserConstant.COLLECTION, {"email": email})
     if user_data is None:
         # Tell the user that their email doesn't exist
         raise UserErrors.UserNotExistError("your User does not exist")
     if not Utils.hash_password(password, user_data['password']):
         # tell user that the password is wrong
         raise UserErrors.IncorrectPasswordError("your password is in correct ")
     return True
Ejemplo n.º 4
0
    def is_login_valid(email, password):
        """
        This method verify that an e-mail/password combo (as sent by the site forms) is valid or not.
        Checks that e-mail exists, and that the password associated to that e-mail is correct.
        :param email: The user's e-mail
        :param password: A sha512 hashed password
        :return: True if valid, False otherwise
        """
        user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})
        if user_data is None:
            # Tell the user that their e-mail doesn't exist.
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell the user that their password is wrong
            raise  UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Ejemplo n.º 5
0
    def is_login_valid(email, password):
        """
        Method Verifies if email and combo is valid
        if email exist and password associated with that email is correct
        :param email: The user's email
        :param password: A sha512 hashed password
        :return True if valid, False otherwise
        """

        user_data = Database.find_one(
            "users", {"email": email})  # Password in sha512 -> pbkdf2_sha512
        if user_data is None:
            # Tell user that their email doesnt exist
            raise UserErrors.UserNotExistsError("User Doesn't Exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell user that the password is wrong
            raise UserErrors.IncorrectPasswordError("Password is wrong")

        return True
Ejemplo n.º 6
0
    def is_login_valid(email, password):
        """
        This method verifies that an email and password combo(as sent by the site forms) is valid or not.
        Checks that the email exists and the password associated with it is correct.
        :param email: The user's email
        :param password: A sha512 hashed password
        :return: True if valid, False otherwise
        """
        user_data = Database.find_user_email(
            email)  # password in sha512-> pbkdf2_sha512
        if user_data is None:
            # tell the user the email does not exists
            raise UserErrors.UserNotExistsError("This email does not exists.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # tell the user that the password is incorrect
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")
        if user_data['email_verified'] != 'yes':
            raise UserErrors.EmailNotVerfiedError(
                "Please verify your e-mail before accessing your dashboard.")

        return True
Ejemplo n.º 7
0
    def is_login_valid(email, password):
        """
        This method verifies that an email/password combo (as sent by the site forms) is valid or not.
        Chacks that the e-mail exists, and that the password associated to that email is correct.
        :param email: The user's email
        :param password: A sha512 hashed password
        :return: True if valid, Flase otherwise
        """

        user_data = Database.find_one(
            UserConstants.COLLECTION,
            {"email": email})  # password in sha512 -> pbkdf2_sha512
        if user_data is None:

            raise UserErrors.UserNotExistsError(
                "Your user does not exist. If you want to login, then register."
            )

        elif not Utils.check_hashed_password(password, user_data['password']):

            raise UserErrors.IncorrectPasswordError(
                "Your password was wrong. Please try again.")

        return True