diff options
Diffstat (limited to 'tools/mmd')
-rw-r--r-- | tools/mmd/MmdCommands.py | 13 | ||||
-rw-r--r-- | tools/mmd/MmdDb.py | 4 | ||||
-rw-r--r-- | tools/mmd/MmdSession.py | 14 | ||||
-rw-r--r-- | tools/mmd/MmdUser.py | 6 | ||||
-rw-r--r-- | tools/mmd/MmdWidgets.py | 2 |
5 files changed, 18 insertions, 21 deletions
diff --git a/tools/mmd/MmdCommands.py b/tools/mmd/MmdCommands.py index d33190b..41f1178 100644 --- a/tools/mmd/MmdCommands.py +++ b/tools/mmd/MmdCommands.py @@ -17,8 +17,6 @@ def login (session): evaluate data from loginForm """ email = escape (session.qs.get ('email', [''])[0]) - # check for account - # verify password return indexWidget (dataWidget (), loginWidget (email), statusWidget (session)) def registerForm (session): @@ -46,23 +44,22 @@ def register (session): user = User () code = user.create (session.session_id, firstname, lastname, email, callsign, longitude, latitude, password) - user.email = email message = '''From: noreply <noreply@mur.at> -To: {0} +To: "{0} {1}" <{2}> Subject: MMD registration confirmation request -Good day! +Dear {0} {1}, -Someone (probably you) has registered at the MURSAT1 Mission Dashbaord +someone (probably you) has registered at the MURSAT1 Mission Dashbaord (MMD) at http://sat.mur.at/dashboard. Please confirm the registration using the link below: - http://hofos.at/mmd/?cmd=completeRegistration&code={1} + http://hofos.at/mmd/?cmd=completeRegistration&code={3} Regards, MURSAT1 team -'''.format (user.email, code) +'''.format (user.firstname, user.lastname, user.email, code) if not user.sendEmail (message): error_message = {'error': 'Email', 'description': 'Email could not be sent.'} diff --git a/tools/mmd/MmdDb.py b/tools/mmd/MmdDb.py index cba395d..d561f3f 100644 --- a/tools/mmd/MmdDb.py +++ b/tools/mmd/MmdDb.py @@ -17,8 +17,8 @@ class Db: self.cursor.execute ('SELECT * FROM session WHERE id=?', (session_id,)) return self.cursor.fetchone () - def sessionInit (self, session_id, email, expires): - self.cursor.execute ('INSERT INTO session (id, email, expires) VALUES (?,?,?)', (session_id, email, expires,)) + def sessionInit (self, session_id, email, expires, status): + self.cursor.execute ('INSERT INTO session (id, email, expires, status) VALUES (?,?,?,?)', (session_id, email, expires, status,)) self.conn.commit () def sessionDelete (self, session_id): diff --git a/tools/mmd/MmdSession.py b/tools/mmd/MmdSession.py index 2dda34e..84230c6 100644 --- a/tools/mmd/MmdSession.py +++ b/tools/mmd/MmdSession.py @@ -3,6 +3,7 @@ Session class for MURSAT1 Mission Dashboard """ from cgi import parse_qs, escape from MmdDb import Db +from MmdUser import User import time # session timeout set to 10 minutes (600 seconds) @@ -12,15 +13,15 @@ class Session: def __init__ (self, session_id): self.session_id = session_id - self.email = 'Anonymous' self.status = 'anon' self.headers = [] self.db = Db () + self.user = User () s = self.db.sessionFind (session_id) if not s: - self.db.sessionInit (self.session_id, self.email, int (time.strftime ('%s')) + timeout) + self.db.sessionInit (self.session_id, self.user.email, int (time.strftime ('%s')) + timeout, self.status) else: - self.email = s['email'] + self.user.load (s['email']) self.status = s['status'] def addHeader (self, header): @@ -29,16 +30,11 @@ class Session: def update (self): self.db.sessionUpdate (self.session_id, int (time.strftime ('%s')) + timeout) - def setEmail (self, email = 'Anonymous'): - self.email = email - self.db.sessionSetEmail (self.session_id, self.email) - def setStatus (self, status = 'anon'): self.status = status self.db.sessionSetStatus (self.session_id, self.status) - def authenticate (self, user): - self.setEmail (user.email) + def authenticate (self): self.setStatus ('auth') def valid (self): diff --git a/tools/mmd/MmdUser.py b/tools/mmd/MmdUser.py index c7d0ee0..db6754b 100644 --- a/tools/mmd/MmdUser.py +++ b/tools/mmd/MmdUser.py @@ -9,14 +9,18 @@ from MmdDb import Db class User: - def __init__ (self): + def __init__ (self, email = 'Anonymous'): self.db = Db () + self.email = email def create (self, user_id, firstname, lastname, email, callsign, longitude, latitude, password): password_hash = hashlib.sha1 (password).hexdigest () code = hashlib.sha1 ('{0}{1}{2}{3}'.format (user_id, firstname, lastname, email)).hexdigest () regtimeout = int (time.strftime ('%s')) + (3600 * 24) self.db.userCreate (user_id, firstname, lastname, email, callsign, password_hash, code, regtimeout) + self.email = email + self.firstname = firstname + self.lastname = lastname return code def findPending (self, code): diff --git a/tools/mmd/MmdWidgets.py b/tools/mmd/MmdWidgets.py index 1c83ac5..f0a555a 100644 --- a/tools/mmd/MmdWidgets.py +++ b/tools/mmd/MmdWidgets.py @@ -166,7 +166,7 @@ def statusWidget (session): <div id="info"> Hello {0} with session id '{1}'! Local time is {2}. {3} </div> - '''.format (session.email, session.session_id, time.strftime ('%c'), inout) + '''.format (session.user.email, session.session_id, time.strftime ('%c'), inout) return html |