Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add an auth model
  • Loading branch information
tdemin committed Jun 4, 2019
1 parent 65e3e02 commit dca1965
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions project_amber/app.py
Expand Up @@ -6,6 +6,7 @@
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = config["database"]
db = SQLAlchemy(app)

db.create_all() # create all tables on first run

@app.route("/")
Expand Down
19 changes: 19 additions & 0 deletions project_amber/models/auth.py
@@ -0,0 +1,19 @@
from project_amber.app import db

class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), unique=True, nullable=False)
password = db.Column(db.String(256))
def __repr__(self):
return "<User id='%d' name='%s'>" % self.id, self.name

class Session(db.Model):
"""
Holds auth session details (auth token, the time of login, etc).
"""
token = db.Column(db.String(256), primary_key=True)
user = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
loginTime = db.Column(db.Integer, nullable=False)
def __repr__(self):
return "<Session token='%s' user='%d' loginTime='%d'>" % \
self.token, self.user, self.loginTime

0 comments on commit dca1965

Please sign in to comment.