Example #1
0
 def login(self, email: str, pwd: str):
     if len(pwd) == 0:
         raise Exception('Password required')
     if len(email) == 0:
         raise Exception('Email required')
     if not self.is_valid_email(email):
         raise Exception('Email not valid')
     user = Users.login(email, pwd)
Example #2
0
    def new(self, fields):
        if len(fields[0]) == 0:
            raise Exception('First name required')
        if len(fields[1]) == 0:
            raise Exception('Last name required')
        if len(fields[2]) == 0:
            raise Exception('Email required')
        if not self.is_valid_email(fields[2]):
            raise Exception('Email not valid')
        user = Users.new(fields)

        print(fields[0])
        print(fields[1])
        print(fields[2])
        print(fields[3])
        self.send_mail(user.email, user.token)
        return
Example #3
0
 def delete(self, id: int):
     return Users.delete(id)
Example #4
0
 def edit(self, fields: list, id: int):
     return Users.edit(fields, id)
Example #5
0
 def get_all(self):
     return Users.get_all()
Example #6
0
 def find_by_id(id: int):
     return Users.find_by_id(id)
Example #7
0
 def change_password(self, id, password):
     return Users.change_password(id, password)
Example #8
0
 def check_token(self, token):
     our_user = Users.check_token(token)
     if our_user is not None:
         return our_user.id
     return 0