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)
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
def delete(self, id: int): return Users.delete(id)
def edit(self, fields: list, id: int): return Users.edit(fields, id)
def get_all(self): return Users.get_all()
def find_by_id(id: int): return Users.find_by_id(id)
def change_password(self, id, password): return Users.change_password(id, password)
def check_token(self, token): our_user = Users.check_token(token) if our_user is not None: return our_user.id return 0