aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask/model.py
diff options
context:
space:
mode:
authorSam2013-10-07 02:14:41 -0500
committerSam2013-10-07 02:14:41 -0500
commita55a1b941864a9574b8177349b8c9c750f379c72 (patch)
treec0e0e1ea8ad7853d0d66e6a7b6bead5eaf01046c /wqflask/wqflask/model.py
parente13f0c576ca75af57abac83851d206e113dabaad (diff)
downloadgenenetwork2-a55a1b941864a9574b8177349b8c9c750f379c72.tar.gz
Worked on logins, session_ids, flash messages, etc.
Diffstat (limited to 'wqflask/wqflask/model.py')
-rw-r--r--wqflask/wqflask/model.py12
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)