Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devgiordane/0fc507f5f11742ae5b90ced8a509cd14 to your computer and use it in GitHub Desktop.
Save devgiordane/0fc507f5f11742ae5b90ced8a509cd14 to your computer and use it in GitHub Desktop.
model.py
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