diff options
author | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-28 22:21:53 +0200 |
---|---|---|
committer | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-28 22:21:53 +0200 |
commit | 220941cad39f1d0e5d75c219e62ec11d9ec0799b (patch) | |
tree | 6009043a2bf9f2a07a47dba2bbb2faaec4e58980 | |
parent | ee35835b75119e57dd23f13fba95c02e50125a44 (diff) | |
download | web-220941cad39f1d0e5d75c219e62ec11d9ec0799b.tar.gz web-220941cad39f1d0e5d75c219e62ec11d9ec0799b.tar.bz2 web-220941cad39f1d0e5d75c219e62ec11d9ec0799b.zip |
added possibility to delete service passwords
-rw-r--r-- | account.py | 24 | ||||
-rw-r--r-- | app.py | 5 | ||||
-rw-r--r-- | static/layout.css | 8 | ||||
-rw-r--r-- | templates/settings.html | 23 |
4 files changed, 42 insertions, 18 deletions
@@ -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 @@ -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 %} |