summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--account.py24
-rw-r--r--app.py5
-rw-r--r--static/layout.css8
-rw-r--r--templates/settings.html23
4 files changed, 42 insertions, 18 deletions
diff --git a/account.py b/account.py
index 14af184..2ef2e41 100644
--- a/account.py
+++ b/account.py
@@ -276,16 +276,23 @@ class AccountService:
for service, passwords in account.new_password_services.items():
dn = self._format_dn([('uid',account.uid),('cn',service),('ou','services')])
+ old, new = passwords
- if service not in account.services:
- attr = [('objectClass', ['top', 'servicePassword']), ('uid', account.uid)]
- self.connection.add_s(dn, attr)
+ if new != None:
+ if service not in account.services:
+ attr = [('objectClass', ['top', 'servicePassword']), ('uid', account.uid)]
+ self.connection.add_s(dn, attr)
+
+ if as_admin:
+ self.connection.passwd_s(dn, None, new)
+ else:
+ self.connection.passwd_s(dn, old, new)
- old, new = passwords
- if as_admin:
- self.connection.passwd_s(dn, None, new)
else:
- self.connection.passwd_s(dn, old, new)
+ s = service.lower()
+ if s in account.services:
+ self.connection.delete_s(dn)
+ account.services.remove(s)
account.new_password_services = {}
@@ -321,6 +328,9 @@ class Account:
return "<Account uid=%s>" % self.uid
+ def reset_password(self, service):
+ self.new_password_services[service] = (None, None)
+
def change_password(self, new_password, old_password='', service=None):
"""
Changes a password for a given service. You have to use the
diff --git a/app.py b/app.py
index adc2eb8..3227540 100644
--- a/app.py
+++ b/app.py
@@ -181,6 +181,11 @@ def lost_password_complete(token):
@templated('settings.html')
@login_required
def settings():
+ s = request.args.get('delete_service_password', None)
+ if request.method == 'GET' and s:
+ g.user.reset_password(s)
+ g.ldap.update(g.user, as_admin=True) #XXX: as_admin wieder wegmachen sobald ACLs richtig gesetzt sind
+
form = SettingsForm(request.form, mail=g.user.mail)
if request.method == 'POST' and form.validate():
changed = False
diff --git a/static/layout.css b/static/layout.css
index 5f6b4ad..7c92335 100644
--- a/static/layout.css
+++ b/static/layout.css
@@ -134,6 +134,14 @@ form ul.errors {
padding-left: 1em;
}
+span.active {
+ color: green;
+}
+
+span.inactive {
+ color: red;
+}
+
/* flashing */
ul.flashes {
diff --git a/templates/settings.html b/templates/settings.html
index 3189d6a..646f6b8 100644
--- a/templates/settings.html
+++ b/templates/settings.html
@@ -10,21 +10,22 @@
{{ render_csrf(form) }}
<div class="form-actions"><input type="submit" value="Speichern" name="submit_main" /></div>
- <!--
<h2>Dienste verwalten</h2>
{%- for service in services %}
- <h3>{{ service.name }}</h3>
- {%- if service.changed %}
- <p>Eigenes Passwort gesetzt</p>
- <p>löschen, todo</p>
- <p>Ändern:</p>
- {%- else %}
- <p>Kein eigenes Passwort gesetzt.</p>
- <p>Eigenes Passwort setzen:</p>
- {%- endif %}
+ <h3>
+ {{ service.name }}
+ <small>
+ {%- if service.changed %}
+ <span class="active">aktiv</span>
+ <a href="{{ url_for('settings',delete_service_password=service.name)}}">löschen</a>
+ {%- else %}
+ <span class="inactive">inaktiv</span>
+ {%- endif %}
+ </small>
+ </h3>
+ <p>Neues Passwort setzen:</p>
{{ render_field(form.get_servicepassword(service.id)) }}
{{ render_field(form.get_servicepasswordconfirm(service.id)) }}
{%- endfor %}
- -->
</form>
{%- endblock %}