summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarian Sigler <m@qjym.de>2012-10-07 23:38:30 +0200
committerMarian Sigler <m@qjym.de>2012-10-07 23:38:30 +0200
commit752c33ad6a412d496fece6876e48ab6c7e2474a4 (patch)
tree4a7de3e9d9bf1e1b149c6c9b3511a0d41f68b643
parentb52de923cbb794b8dbc4d94c60c38088e26d95b5 (diff)
downloadweb-752c33ad6a412d496fece6876e48ab6c7e2474a4.tar.gz
web-752c33ad6a412d496fece6876e48ab6c7e2474a4.tar.bz2
web-752c33ad6a412d496fece6876e48ab6c7e2474a4.zip
Add "captcha"; Send mail when a new account is created.
-rw-r--r--app.py8
-rw-r--r--default_settings.py3
-rw-r--r--forms.py4
-rw-r--r--templates/about.html4
-rw-r--r--templates/register.html1
-rw-r--r--utils.py3
6 files changed, 18 insertions, 5 deletions
diff --git a/app.py b/app.py
index bb4b072..6c64043 100644
--- a/app.py
+++ b/app.py
@@ -113,6 +113,14 @@ def register_complete(token):
# populate request context and session
assert login_user(user.uid, user.password)
+ if app.config.get('MAIL_REGISTER_NOTIFY'):
+ print 'mail versandt an %s' % app.config['MAIL_REGISTER_NOTIFY']
+ send_mail(
+ app.config['MAIL_REGISTER_NOTIFY'],
+ u'[accounts] Neuer Benutzer %s' % username,
+ 'Benutzername: %s\nE-Mail: %s\n' % (username, mail)
+ )
+
flash(u'Benutzer erfolgreich angelegt.', 'success')
return redirect(url_for('settings'))
diff --git a/default_settings.py b/default_settings.py
index 2a74829..62337ac 100644
--- a/default_settings.py
+++ b/default_settings.py
@@ -8,7 +8,8 @@ SECRET_KEY = 'remember to change this to something more random and secret'
PASSWORD_ENCRYPTION_KEY = '.\x14\xa7\x1b\xa2:\x1b\xb7\xbck\x1bD w\xab\x87a\xb4\xb7\xca\xf1\x06\xb0\x9f?q\x13\x05\x8dY\xe5<'
MAIL_DEFAULT_SENDER = 'help-me-help-me-please@spline.de'
-MAIL_CONFIRM_SENDER = 'spline accounts <noreply@account.spline.de>'
+MAIL_CONFIRM_SENDER = 'spline accounts <noreply@accounts.spline.de>'
+MAIL_REGISTER_NOTIFY = None
SENDMAIL_COMMAND = '/usr/sbin/sendmail'
diff --git a/forms.py b/forms.py
index b14e612..963ef6e 100644
--- a/forms.py
+++ b/forms.py
@@ -19,6 +19,8 @@ class RegisterForm(Form):
NotRegexp(_username_exclude_re, message=u'Dieser Benutzername ist nicht erlaubt.'),
])
mail = TextField('E-Mail-Adresse', [validators.Email(), validators.Length(min=6, max=50)])
+ question = TextField('Hauptstadt von Deutschland?', [validators.AnyOf(('Berlin', 'berlin'),
+ message=u'Bitte beantworte die Frage.')])
def validate_username(form, field):
try:
@@ -30,7 +32,7 @@ class RegisterForm(Form):
raise ValidationError(Markup(u'Dieser Benutzername ist momentan nicht erlaubt. '
u'<a href="%s">Weitere Informationen</a>' % url_for('about')))
else:
- raise ValidationError(u'Dieser Benutzername ist schon vergeben')
+ raise ValidationError(u'Dieser Benutzername ist schon vergeben.')
def validate_mail(form, field):
#TODO
diff --git a/templates/about.html b/templates/about.html
index 3056e97..ceb1fc8 100644
--- a/templates/about.html
+++ b/templates/about.html
@@ -25,8 +25,8 @@
</p>
<p>
Wenn du schon einen Benutzernamen in einem der alten Dienste hast, kannst
- du uns Bescheid sagen, dann erstellen wir dir von Hand einen Account.
-{# TODO: kontaktmöglichkeit #}
+ du uns <a href="mailto:accounts@spline.de">Bescheid sagen</a>, dann
+ erstellen wir dir von Hand einen Account.
</p>
<h2>Welche Dienste sind bisher dabei?</h2>
<ul>
diff --git a/templates/register.html b/templates/register.html
index e724e2f..7f56280 100644
--- a/templates/register.html
+++ b/templates/register.html
@@ -16,6 +16,7 @@
<form action="{{ url_for('register') }}" method="post" class="form-horizontal">
{{ render_field(form.username, autofocus="autofocus") }}
{{ render_field(form.mail) }}
+ {{ render_field(form.question) }}
{{ render_submit(value='E-Mail-Adresse bestätigen')}}
</form>
{%- endblock %}
diff --git a/utils.py b/utils.py
index 595f770..8397344 100644
--- a/utils.py
+++ b/utils.py
@@ -234,7 +234,8 @@ def url_for(endpoint, **values):
"""Wrap `flask.url_for` so that it always returns https links"""
#XXX: Drop this in favor of config.PREFERRED_URL_SCHEME when we require Flask 0.9
u = flask_url_for(endpoint, **values)
- if '_external' in values and u.startswith('http://'):
+ if '_external' in values and u.startswith('http://') \
+ and current_app.config['PREFERRED_URL_SCHEME'] == 'https':
return 'https://' + u[7:]
else:
return u