Exemplo n.º 1
0
 def is_login_valid(email, password):
     user_data = Database.find_one("users", {'email': email})
     if user_data is None:
         raise UserErrors.UserNotExistError("Your User Does not exist!")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError("Your Password was Wrong!")
     return True
Exemplo n.º 2
0
 def login_valid(email, password):
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistError("Your user does not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError("Your password was wrong")
     return True
Exemplo n.º 3
0
 def is_login_valid(email, sha512_password):
     user_data = Database.find_one(collection='users',
                                   query={'email': email})
     if user_data is None:
         raise UserErrors.UserNotExistError("User doesn't exist.")
     if not Utils.check_hashed_password(sha512_password,
                                        user_data['hashed_password']):
         raise UserErrors.UserIncorrectPasswordError("Incorrect password.")
     return True
Exemplo n.º 4
0
 def is_login_valid(email, password):  # Password in sha512 -> pbkdf2_sha512
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is None:
         # Tell User email doesn't exist
         raise err.UserNotExistError("Your user does not exists.")
     if not Utils.check_hash_password(password, user_data['password']):
         # Tell the user that their password is wrong
         raise err.IncorrectPassword("Your password was wrong.")
     return True
Exemplo n.º 5
0
 def is_login_valid(email, password):
     """
     
     :param email: 
     :param password: 
     :return: 
     """
     user_data = Database.find_one("users", {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistError('Your user does not exist')
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError(
             'your password is not correct')
     return True
Exemplo n.º 6
0
 def login_valid(email, password):
     """
     This method verifies that an email/pw combo is valid
     :param email: user's email
     :param password: a sha512 hashed password
     :return: true if valid else false
     """
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistError("Your user does not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError("Your password was wrong")
     return True
Exemplo 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
     :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 the user that their email donesnt exist
         raise UserErrors.UserNotExistError("Your user doesn't 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
Exemplo n.º 8
0
    def is_login_valid(email, password):
        """  Verify email and password combo

        this method verifies that an email password combo is valid
        email exists, and password is correct
        :param email:   user's email (string)
        :param password:   a SHA512 hashed password
        :return: true if valid false otherwise
        """
        user_data = User.get_from_db_by_email(email)
        if user_data is None:  # raise an error if user does not exist
            raise user_errors.UserNotExistError('Your user does not exist')
        else:
            if not Utils.check_hashed_password(password, user_data['password']):
                raise user_errors.IncorrectPasswordError('Password mismatch')
            else:
                return True  # user is there AND password matches
Exemplo n.º 9
0
 def is_login_valid(email, password):
     """
     This method verifies that email / password combo is valid.
     Check if the email exist and if the password associate is correct
     :param email: The user's email
     :param password: A sha12 hashed password
     :return:True if valid, False if wrong
     """
     user_data = Database.find_one(UserCOnstants.COLLECTION,
                                   {"email": email})
     if user_data is None:
         # email not exist
         raise UserErrors.UserNotExistError("Your user does not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         # tell user password is wrong
         raise UserErrors.IncorrectPasswordError("Your password is wrong")
     return True
Exemplo n.º 10
0
    def is_login_valid(email, password):
        """
        To verify whether the email/pw pair is valid.
        :param email: A string
        :param password: A (sha25) hashed password
        :return: True if valid, otherwise False
        """
        user_data = Database.find_one(collection=UserConstants.COLLECTION, query={"email": email})
        # The pw contained in user_data is already hashed to pbkdf2_sha512

        if user_data is None:
            # This user does not exist
            raise UserErrors.UserNotExistError("This user does not exist.")
        if Utils.check_hashed_password(password, user_data["password"]) is not True:
            # Tell the user the pw is not correct
            raise UserErrors.IncorrectPasswordError("Your pw is not correct.")

        return True
Exemplo n.º 11
0
    def is_login_valid(email, password):
        '''
        To verify if the email and associated password are valid
        :param email: user's email
        :param password: sha512 hashed password
        :return: True if valid False otherwise
        '''
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"email": email})
        if user_data is None:
            #Tell user that email does not exist
            raise UserErrors.UserNotExistError("The user does not exist")

        if not Utils.check_hashed_password(password, user_data['password']):
            #Tell user that their password is wrong
            raise UserErrors.IncorrectPasswordError("Your Password is wrong")

        return True
Exemplo n.º 12
0
    def is_valid_login(email, password):
        """
        This method verifies that an e-mail/password combo (sent from the website) is valid or not
        Checks that the email exists and the password specified is correct
        :param email: The User's e-mail
        :param password: A sha512 hashed password
        :return: True if valid, else False
        """

        user_data = Database.find_one(collection=UserConstants.COLLECTION,
                                      query={"email": email})
        if user_data is None:
            raise UserErrors.UserNotExistError("Your User does not Exist")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError(
                "Your Password is incorrect")

        return True
Exemplo n.º 13
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo (as sent by the site forms) is valid.
        Checks that the e-mail exists, and that the password associated to that e-mail 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(
            UserConstants.COLLECTION,
            {"email": email})  #Password in pbkdf2_sha512
        if user_data is None:
            # tell user that their e-mail doesn't exist
            raise UserErrors.UserNotExistError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # tell user that their password is wrong
            raise UserErrors.IncorrectPasswordError("Your password is wrong.")

        return True
Exemplo n.º 14
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo (as sent by the sitr forms) is valid or not.
        Checks taht the e-mail exists, and that the password associate 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(
            "users", {"email": email})  # password in sha512 -> pbkdf2_sha512

        if user_data is None:
            # Tell the user that their email does not exist
            raise UserErrors.UserNotExistError(
                "Username does not exist or invalid.")

        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell the user that their password is incorrect
            raise UserErrors.IncorrectPasswordError("Password is incorrect.")

        return True
Exemplo n.º 15
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo(as sent by the site forms) is valid or not.
        Checks that the e-mail exists, and password associated to that e-mail 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(
            UserConstants.COLLECTION,
            query={"email": email})  # password in pbkdf2_sha512 format
        if user_data is None:
            # Users donot exists. Raise exception
            raise UserErrors.UserNotExistError(
                "User name entered does not exist.")

        if not Utils.check_hashed_passwords(password, user_data['password']):
            # Tells that the password donot matches. Raise exception
            raise UserErrors.IncorrectPasswordError(
                "Your password does not matches.")

        return True