Ejemplo n.º 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.')
Ejemplo n.º 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.")
Ejemplo n.º 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
Ejemplo n.º 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.')
Ejemplo n.º 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.')
Ejemplo n.º 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.')
Ejemplo n.º 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')
Ejemplo n.º 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.')
Ejemplo n.º 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
Ejemplo n.º 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")
Ejemplo n.º 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.')
Ejemplo n.º 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 ! ")
Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 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.')
Ejemplo n.º 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.')
Ejemplo n.º 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')
Ejemplo n.º 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.")