Example #1
0
 def find_by_email(cls, email: str):
     try:
         return Database.find(email)
     except TypeError:
         # user not found by email
         raise errors.UserNotFoundError(
             'A user with this email was not found.')
Example #2
0
    def find_by_email(cls, email: str) -> User:
        """
        Finds a :class:`.User` by email.

        Parameters
        ----------
        email : str
            The email to query by.

        Returns
        -------
        User
            The :class:`.User` corresponding to the query.

        Raises
        ------
        UserErrors.UserNotFoundError
            If the :class:`.User` was not found.

        """
        try:
            return cls.find_one_by('email', email)
        except TypeError:
            raise UserErrors.UserNotFoundError(
                "A user with this e-mail was not found.")
Example #3
0
 def validate_login(cls, email: str, password: str) -> bool:
     user = cls.find_by_email(email)
     if not user:
         raise UserErrors.UserNotFoundError('User not found.')
     if not Utils.verify_password(password, user.password):
         raise UserErrors.PasswordEmailNotMatching(
             'Password does not match the account attached to this email.')
     return True
Example #4
0
 def find_by_username(cls, username: str) -> 'User':
     """
     Search the database using the username.
     """
     try:
         return cls.find_one_by(username=username)
     except TypeError:
         raise errors.UserNotFoundError(
             'The username you have entered does not match any account.')
Example #5
0
 def find_by_email(cls, email: str) -> "User":
     """
     This method searches the database for user's email and raises an exception if not found
     :param email: The email input into the login page
     :return: The record if the email was found
     """
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             'A User with this e-mail was not found.')
Example #6
0
 def find_by_email(cls, email: str) -> 'User':
     """
     this one is also gonna try sth, try return find_one_by email, but if failed got UserErrors
     :param email:
     :return: User class
     """
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             'A user with this e-mail was not found.')
Example #7
0
 def find_by_email(cls, email):
     print(type(email))
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError('No se encontrĂ³ un usuario')
Example #8
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         # raise one of these custom errors when we cannot find the user in the database
         raise UserErrors.UserNotFoundError('A user with this e-mail was not found.')
Example #9
0
 def find_by_email(cls, email: str) -> "User":
     found = cls.find_one_by("email", email)
     if found is None:
         raise UserErrors.UserNotFoundError("A  user with this e-mail was not found!")
     return found
Example #10
0
 def find_by_email(cls, email: str) -> "Customer":
     try:
         return cls.find_one_by("email", email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             "Customer with this email not found")
Example #11
0
 def find_by_email(cls, email: str):
     try:
         return cls.find_one_by("email", email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             'No user found attached to that e-mail.')
Example #12
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by("email", email)
     except IndexError:
         raise UserErrors.UserNotFoundError("A user with this e-mail was not found in the database ! ")
Example #13
0
 def find_by_email(cls, email: str) -> "List[User]":
     try:
         user = cls.find_one_by('email', email)
         return user
     except TypeError:
         raise UserErrors.UserNotFoundError('A user with this email id is not found')
Example #14
0
 def find_by_email(cls, email) -> "User":
     try:
         return cls.find_one_by("email", email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             "A user with this email was not found")
Example #15
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             'A user with this e-mail was not found.')
Example #16
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError(
             'User with this email does not exist.')
Example #17
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by('email', email)
     except TypeError:
         raise UserErrors.UserNotFoundError('Email not found')
Example #18
0
 def find_by_email(cls, email: str) -> "User":
     try:
         return cls.find_one_by("email", email)
     except TypeError:
         raise UserErrors.UserNotFoundError("User not found.")