Created
April 3, 2021 14:20
-
-
Save devgiordane/0fc507f5f11742ae5b90ced8a509cd14 to your computer and use it in GitHub Desktop.
model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(ModelBase): | |
email = TextField(unique=True) | |
name = TextField() | |
password = TextField() | |
def login(self, email, password): | |
user = self.select().where(self.email==email).get() | |
if user and user.password == password: | |
return user | |
return None | |
def register(self, email, password): | |
user = self(email=email, password=password) | |
try: | |
user.save() | |
return user | |
except: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment