summaryrefslogtreecommitdiff
path: root/tools/mmd
diff options
context:
space:
mode:
authorJogi Hofmüller <jogi@mur.at>2011-07-31 16:38:40 +0000
committerJogi Hofmüller <jogi@mur.at>2011-07-31 16:38:40 +0000
commite6d1c7edf7be72017877fb9f5b77229afbea29f0 (patch)
tree2c4987953d432ee8f93dde617cc77fcd2ed8453a /tools/mmd
parent- new module MmdUser.py (diff)
- have a confirmation request sent by email for registration now
* still trouble with unicode/utf-8 characters entered in form ... git-svn-id: https://svn.spreadspace.org/mur.sat@86 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/mmd')
-rw-r--r--tools/mmd/MmdCommands.py24
-rw-r--r--tools/mmd/MmdDb.py9
-rw-r--r--tools/mmd/MmdUser.py16
-rw-r--r--tools/mmd/MmdWidgets.py9
4 files changed, 49 insertions, 9 deletions
diff --git a/tools/mmd/MmdCommands.py b/tools/mmd/MmdCommands.py
index 19a5968..0ac98da 100644
--- a/tools/mmd/MmdCommands.py
+++ b/tools/mmd/MmdCommands.py
@@ -41,12 +41,32 @@ def register (session):
confirm = session.getQsConfirm ()
if password != confirm:
- error_message = {'error': 'Password', 'description': 'Passwords do not match'}
+ error_message = {'error': 'Password', 'description': 'Passwords do not match.'}
return indexWidget (dataWidget (), errorWidget (error_message), statusWidget (session.session_id, session.email))
user = User ()
- user.create (session.session_id, firstname, lastname, email, callsign, longitude, latitude, password)
+ confreg = user.create (session.session_id, firstname, lastname, email, callsign, longitude, latitude, password)
+ user.email = email
+ message = '''From: noreply <noreply@mur.at>
+To: {0}
+Subject: MMD registration confirmation request
+Good day!
+
+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/mmd?cmd=confirmRegistration&code={1}
+
+Regards,
+MURSAT1 team
+'''.format (user.email, confreg)
+
+ if not user.sendEmail (message):
+ error_message = {'error': 'Email', 'description': 'Email could not be sent.'}
+ return indexWidget (dataWidget (), errorWidget (error_message), statusWidget (session.session_id, session.email))
return indexWidget (dataWidget (), registerWidget (), statusWidget (session.session_id, session.email))
diff --git a/tools/mmd/MmdDb.py b/tools/mmd/MmdDb.py
index 640a8ff..18a4df8 100644
--- a/tools/mmd/MmdDb.py
+++ b/tools/mmd/MmdDb.py
@@ -39,9 +39,12 @@ class Db:
self.conn.commit ()
return self.cursor.rowcount
- def userCreate (self, user_id, firstname, lastname, email, callsign, password):
- self.cursor.execute ('INSERT INTO user (id, firstname, lastname, email, callsign, password) VALUES (?,?,?,?,?,?)',
- (user_id, firstname, lastname, email, callsign, password))
+ #
+ # user related methods
+ #
+ def userCreate (self, user_id, firstname, lastname, email, callsign, password, confreg):
+ self.cursor.execute ('INSERT INTO user (id, firstname, lastname, email, callsign, password, confreg) VALUES (?,?,?,?,?,?,?)',
+ (user_id, firstname, lastname, email, callsign, password, confreg))
self.conn.commit ()
def close (self):
diff --git a/tools/mmd/MmdUser.py b/tools/mmd/MmdUser.py
index 86e0a3d..ee45e72 100644
--- a/tools/mmd/MmdUser.py
+++ b/tools/mmd/MmdUser.py
@@ -2,6 +2,7 @@
User class for MURSAT1 Mission Dashboard
"""
import hashlib
+import smtplib
from cgi import parse_qs, escape
from MmdDb import Db
@@ -12,7 +13,20 @@ class User:
def create (self, user_id, firstname, lastname, email, callsign, longitude, latitude, password):
password_hash = hashlib.sha1 (password).hexdigest ()
- self.db.userCreate (user_id, firstname, lastname, email, callsign, password_hash)
+ token = str ('{0}{1}{2}{3}'.format (user_id, firstname, lastname, email))
+ confreg = hashlib.sha1 (token).hexdigest ()
+ self.db.userCreate (user_id, firstname, lastname, email, callsign, password_hash, confreg)
+ return confreg
+
+ def sendEmail (self, message):
+ server = smtplib.SMTP ('localhost')
+ try:
+ server.sendmail ('noreply@mur.at', self.email, message)
+ server.quit ()
+ return True
+ except (smtplib.SMTPRecipientsRefused, smtplib.SMTPHeloError, smtplib.SMTPSenderRefused, smtplib.SMTPDataError):
+ server.quit ()
+ return False
if __name__ == "__main__":
pass
diff --git a/tools/mmd/MmdWidgets.py b/tools/mmd/MmdWidgets.py
index 9219e8c..1402410 100644
--- a/tools/mmd/MmdWidgets.py
+++ b/tools/mmd/MmdWidgets.py
@@ -11,7 +11,8 @@ def loginFormWidget ():
<table>
<tr><td class="formfield">Email:</td><td><input type="text" name="email" /></td></tr>
<tr><td class="formfield">Password:</td><td><input type="password" name="password" /></td></tr>
- <tr><td class="formfield"><input type="submit" value="Login" disabled="disabled" /></td><td></td></tr>
+ <tr><td class="formfield"><input type="submit" value="Login" /></td><td></td></tr>
+ <!-- <tr><td class="formfield"><input type="submit" value="Login" disabled="disabled" /></td><td></td></tr> -->
</table>
<input type="hidden" name="cmd" value="login" />
</form>
@@ -40,7 +41,8 @@ def registerFormWidget ():
<tr><td class="formfield">Latitude: </td><td><input type="text" name="longitude" /></td></tr>
<tr><td class="formfield">Password*: </td><td><input type="password" name="password" /></td></tr>
<tr><td class="formfield">Confirm Password*: </td><td><input type="password" name="confirm" /></td></tr>
- <tr><td class="formfield"><input type="submit" value="Register" disabled="disabled" /></td><td></td></tr>
+ <!-- <tr><td class="formfield"><input type="submit" value="Register" disabled="disabled" /></td><td></td></tr> -->
+ <tr><td class="formfield"><input type="submit" value="Register" /></td><td></td></tr>
</table>
<input type="hidden" name="cmd" value="register" />
</form>
@@ -51,7 +53,8 @@ def registerFormWidget ():
def registerWidget ():
html = '''
- you could be registered iff I had finished this code
+ <h3>Thank you for registering!</h3>
+ You will receive an email conataining a link to confirm your registration. Please use this link within 24 hours to complete registration.
'''
return html