From 89ce129b38553b27b1c09bd2cf476a54cbdeba12 Mon Sep 17 00:00:00 2001 From: b3yond Date: Mon, 8 Jan 2018 01:16:34 +0100 Subject: [PATCH] first attempt at confirmation mails --- frontend/login.py | 26 +++++++++++++++++++++++--- static/bot.html | 4 +++- static/index.html | 2 +- static/register.html | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/frontend/login.py b/frontend/login.py index 6dffb8b..a2c79f7 100644 --- a/frontend/login.py +++ b/frontend/login.py @@ -2,6 +2,7 @@ import bottle import sqlite3 +import sendmail class Datagetter(object): def __init__(self): @@ -46,14 +47,33 @@ def register(): :return: bot.py Session Cookie """ - uname = bottle.request.forms.get('email') + email = bottle.request.forms.get('email') psw = bottle.request.forms.get('psw') pswrepeat = bottle.request.forms.get('psw-repeat') if pswrepeat != psw: return "ERROR: Passwords don't match. Try again." - # :todo send confirmation Mail with encoded email+passphrase to email - return "We Sent you an E-Mail. Please click on the confirmation link." + # needs to be encoded somehow + confirmlink = "ticketfrei.links-tech.org/confirm?email=" + email + "&passphrase=" + psw + config = "" + m = sendmail.Mailer(config) + m.send("Complete your registration here: " + confirmlink, email, "[Ticketfrei] Confirm your account") + return "We sent you an E-Mail. Please click on the confirmation link." + + +# How can I parse the arguments from the URI? +# https://ticketfrei.links-tech.org/confirm?user=asdf&pass=sup3rs3cur3 +@app.route('/confirm') +def confirmaccount(): + """ + Confirm the account creation and create a database entry. + :return: Redirection to bot.html + """ + uname = "user" # :todo get user from URI + passphrase = "pass" # :todo get passphrase from URI + active = "1" + db.conn.execute("CREATE ?, ?, ? IN user;", (uname, passphrase, active)) + @app.route('/static/') def static(filename): diff --git a/static/bot.html b/static/bot.html index 0141658..c08345d 100644 --- a/static/bot.html +++ b/static/bot.html @@ -5,7 +5,9 @@
- Ticketfrei Logo +

Ticketfrei

+ + # Is the user logged in? else, complain & show nothing.