def usersuite_change_mail(): """Changes the users forwarding mail attribute in his LDAP entry. TODO: LDAP schema forbids add/replace 'mail' attribute """ form = ChangeMailForm() if form.validate_on_submit(): password = form.password.data email = form.email.data try: change_email(current_user.uid, password, email) except UserNotFound: flash(gettext(u"Nutzer nicht gefunden!"), "error") except PasswordInvalid: flash(gettext(u"Passwort war inkorrekt!"), "error") except LDAPConnectionError: flash(gettext(u"Nicht genügend LDAP-Rechte!"), "error") else: flash(gettext(u"E-Mail-Adresse wurde geändert"), "success") return redirect(url_for('.usersuite')) elif form.is_submitted(): flash_formerrors(form) return render_template('usersuite/change_mail.html', form=form)
def usersuite_delete_mail(): """Resets the users forwarding mail attribute in his LDAP entry. """ form = DeleteMailForm() if form.validate_on_submit(): password = form.password.data try: change_email(current_user.uid, password, "") except UserNotFound: flash(gettext(u"Nutzer nicht gefunden!"), "error") except PasswordInvalid: flash(gettext(u"Passwort war inkorrekt!"), "error") except LDAPConnectionError: flash(gettext(u"Nicht genügend LDAP-Rechte!"), "error") else: flash(gettext(u"E-Mail-Adresse wurde zurückgesetzt"), "success") return redirect(url_for('.usersuite')) elif form.is_submitted(): flash_formerrors(form) return render_template('usersuite/delete_mail.html', form=form)