diff options
author | Sam | 2013-10-07 02:14:41 -0500 |
---|---|---|
committer | Sam | 2013-10-07 02:14:41 -0500 |
commit | a55a1b941864a9574b8177349b8c9c750f379c72 (patch) | |
tree | c0e0e1ea8ad7853d0d66e6a7b6bead5eaf01046c /wqflask/wqflask/model.py | |
parent | e13f0c576ca75af57abac83851d206e113dabaad (diff) | |
download | genenetwork2-a55a1b941864a9574b8177349b8c9c750f379c72.tar.gz |
Worked on logins, session_ids, flash messages, etc.
Diffstat (limited to 'wqflask/wqflask/model.py')
-rw-r--r-- | wqflask/wqflask/model.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 8e7a823e..5c514bde 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -1,7 +1,9 @@ from __future__ import print_function, division, absolute_import import uuid +import datetime +from flask import request from flask.ext.sqlalchemy import SQLAlchemy #from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin @@ -84,9 +86,15 @@ class Login(Base): __tablename__ = "login" id = Column(Unicode(36), primary_key=True, default=lambda: unicode(uuid.uuid4())) user = Column(Unicode(36), ForeignKey('user.id')) - timestamp = Column(DateTime()) + timestamp = Column(DateTime(), default=lambda: datetime.datetime.utcnow()) ip_address = Column(Unicode(39)) - + successful = Column(Boolean(), nullable=False) # False if wrong password was entered + session_id = Column(Text) # Set only if successfully logged in, otherwise should be blank + + def __init__(self, user): + self.user = user.id + self.ip_address = request.remote_addr + # Setup Flask-Security #user_datastore = SQLAlchemyUserDatastore(db, User, Role) |