summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-09-26 20:37:49 +0200
committerNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-09-26 20:37:49 +0200
commit9a9db2c26e52b84a9d690a20a99524a6ef7377d1 (patch)
tree42d777315d722caf20a2dd9b083f08f95c89ff46
parentde3bd39446aad4e95275b4c0757ef0772671425b (diff)
parentc27e5d3d34d01e9584580ce09e71d29c895b8d49 (diff)
downloadweb-9a9db2c26e52b84a9d690a20a99524a6ef7377d1.tar.gz
web-9a9db2c26e52b84a9d690a20a99524a6ef7377d1.tar.bz2
web-9a9db2c26e52b84a9d690a20a99524a6ef7377d1.zip
Merge branch 'master' of ssh://git.spline.de/account-web
Conflicts: account.py
-rw-r--r--account.py9
-rw-r--r--app.py5
-rw-r--r--forms.py2
-rw-r--r--static/layout.css28
-rw-r--r--templates/index.html15
-rw-r--r--templates/settings.html1
6 files changed, 35 insertions, 25 deletions
diff --git a/account.py b/account.py
index 1569e2c..51aabc2 100644
--- a/account.py
+++ b/account.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import ldap
from utils import Service
+from uuid import uuid4
LDAP_HOST = 'ldap://localhost:5678'
@@ -108,12 +109,12 @@ class AccountService:
return users[0]
def find_by_uid(self, uid, wildcard=False):
- return self.find({'uid':uid}, wildcard)
+ return self.find({'uid': uid}, wildcard)
def find_by_mail(self, mail, wildcard=False):
- return self.find({'mail':mail}, wildcard)
+ return self.find({'mail': mail}, wildcard)
- def find(self, filters = {}, wildcard=False):
+ def find(self, filters={}, wildcard=False):
"""
Find accounts by a given filter with key:value semantic)
"""
@@ -128,7 +129,7 @@ class AccountService:
filterstr = '(&%s)' % filterstr
dn = self._format_dn([('ou','users')])
- data = self.connection.search_s(dn,ldap.SCOPE_SUBTREE,filterstr)
+ data = self.connection.search_s(dn, ldap.SCOPE_SUBTREE, filterstr)
accounts = []
for a in data:
diff --git a/app.py b/app.py
index 518be05..7c2a1cf 100644
--- a/app.py
+++ b/app.py
@@ -52,6 +52,7 @@ def index():
@logout_required
def register():
#TODO: check for double uids
+ #TODO: check for double mails
form = RegisterForm(request.form)
if request.method == 'POST' and form.validate():
username = form.username.data
@@ -164,6 +165,7 @@ def settings():
if request.form.get('submit_main'):
if form.mail.data and form.mail.data != g.user.mail:
+ #TODO: check for uniqueness
confirm_token = make_confirmation('change_mail', (g.user.uid, form.mail.data))
confirm_link = url_for('change_mail', token=confirm_token, _external=True)
@@ -179,7 +181,7 @@ def settings():
changed = True
if form.password.data:
- g.user.change_password(form.password.data, session['password'])
+ g.user.change_password(form.password.data, decrypt_password(session['password']))
session['password'] = encrypt_password(form.password.data)
flash(u'Passwort geändert', 'success')
@@ -211,6 +213,7 @@ def settings():
@app.route('/settings/change_mail/<token>')
@login_required
def change_mail(token):
+ #TODO: check for uniqueness
username, mail = http_verify_confirmation('change_mail', token.encode('ascii'), timeout=3*24*60*60)
if g.user.uid != username:
diff --git a/forms.py b/forms.py
index ff54449..a58f98b 100644
--- a/forms.py
+++ b/forms.py
@@ -38,8 +38,6 @@ class LostPasswordForm(Form):
class SettingsForm(Form):
- old_password = PasswordField('Bisheriges Passwort',
- [validators.Required(u'Bitte gib dein (altes) Passwort an, um deine Daten zu ändern.')])
password = PasswordField('Neues Passwort', [validators.Optional(),
validators.EqualTo('password_confirm', message=u'Passwörter stimmen nicht überein')])
password_confirm = PasswordField(u'Passwort bestätigen')
diff --git a/static/layout.css b/static/layout.css
index a5552ed..7f78832 100644
--- a/static/layout.css
+++ b/static/layout.css
@@ -7,6 +7,16 @@
:link:hover, :visited:hover {
text-decoration: underline;
}
+nav ul {
+ list-style: none;
+}
+nav ul li {
+ display: inline;
+}
+nav ul li:not(:last-child):after {
+ content: " · ";
+ color: #aaa;
+}
/* COMMON PAGE ELEMENTS */
@@ -33,14 +43,18 @@ header {
width: 100%;
}
header h1 {
+ font-size: 2em;
margin: 0;
+ max-width: 50%; /* make image smaller on small screens */
+ min-height: 3em;
padding: 0 1em 0;
display: inline-block;
background-color: #333;
- border-bottom-right-radius: 30px;
+ border-bottom-right-radius: .8em;
}
header h1 img {
margin: 0;
+ max-width: 100%;
}
header #roundcornerb,
header #roundcornerw {
@@ -55,7 +69,7 @@ header #roundcornerb {
}
header #roundcornerw {
background-color: white;
- border-top-left-radius: 30px;
+ border-top-left-radius: 1.6em;
}
header nav#mainnav {
@@ -79,16 +93,6 @@ header nav#usermenu {
right: 1em;
}
-header nav ul {
- list-style: none;
-}
-header nav ul li {
- display: inline;
-}
-header nav ul li:not(:last-child):after {
- content: " · ";
- color: #aaa;
-}
header nav#mainnav ul li:not(:last-child):after {
color: #999;
}
diff --git a/templates/index.html b/templates/index.html
index ea5e258..b3bd93c 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,18 +1,23 @@
{%- extends 'base.html' %}
{%- from '_macros.html' import render_field %}
{%- block content %}
-{%- if session.username %}
+
+{%- if g.user %}
<p>Hallo {{ session.username }}. <a href="{{ url_for('settings') }}">Einstellungen</a></p>
{%- else %}
-<p>
- <a href="/register">Account erstellen</a> |
- <a href="/lost_password">Passwort vergessen</a>
-</p>
<form action="{{ url_for('index') }}" method="post" class="form-horizontal">
+ <h2>Login</h2>
+ <p>
+ Willkommen bei <strong>spline accounts</strong>.
+ Melde dich an, informier dich, oder leg einen account an.
+ </p>
{{ render_field(form.username, autofocus="autofocus") }}
{{ render_field(form.password) }}
{{ form.csrf_token }}
<div class="form-actions"><input type="submit" value="Login" /></div>
+ <p class="form-actions"><a href="/register">Account erstellen</a></div>
+ <p class="form-actions"><a href="/lost_password">Passwort vergessen</a></div>
</form>
{%- endif %}
+
{%- endblock %}
diff --git a/templates/settings.html b/templates/settings.html
index de317fb..064e5af 100644
--- a/templates/settings.html
+++ b/templates/settings.html
@@ -3,7 +3,6 @@
{%- set title = 'Einstellungen' %}
{%- block content %}
<form action="{{ url_for('settings') }}" method="post" class="form-horizontal">
- {{ render_field(form.old_password, autofocus="autofocus") }}
<h2>Globale Einstellungen ändern</h2>
{{ render_field(form.mail) }}
{{ render_field(form.password) }}