diff --git a/uffd/selfservice/templates/set_password.html b/uffd/selfservice/templates/set_password.html index a60cfe0d16c617d302de14d17509bf0b702e0883..67f3a5a2ca4dc67c3400fbd8977f1a520537ac96 100644 --- a/uffd/selfservice/templates/set_password.html +++ b/uffd/selfservice/templates/set_password.html @@ -14,7 +14,7 @@ <label for="user-password1">New Password</label> <input type="password" class="form-control" id="user-password1" name="password1" required="required" tabindex = "2"> <small class="form-text text-muted"> - At least 8 characters, no other special requirements. But please don't be stupid and use a password manager. + At least 8 and at most 256 characters, no other special requirements. But please don't be stupid and use a password manager. </small> </div> <div class="form-group col-12"> diff --git a/uffd/selfservice/views.py b/uffd/selfservice/views.py index 1524fe9892e8f5bee843353871a6751ab3be2716..c8c23758152c09a35f31aa3c34e492fdccbb77da 100644 --- a/uffd/selfservice/views.py +++ b/uffd/selfservice/views.py @@ -145,13 +145,18 @@ def send_passwordreset(loginname): send_mail(user.mail, msg) def send_mail(to_address, msg): - server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT']) - if current_app.config['MAIL_USE_STARTTLS']: - server.starttls() - server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD']) - msg['From'] = current_app.config['MAIL_FROM_ADDRESS'] - msg['To'] = to_address - msg['Date'] = email.utils.formatdate(localtime=1) - msg['Message-ID'] = email.utils.make_msgid() - server.send_message(msg) - server.quit() + try: + server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT']) + if current_app.config['MAIL_USE_STARTTLS']: + server.starttls() + server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD']) + msg['From'] = current_app.config['MAIL_FROM_ADDRESS'] + msg['To'] = to_address + msg['Date'] = email.utils.formatdate(localtime=1) + msg['Message-ID'] = email.utils.make_msgid() + server.send_message(msg) + server.quit() + return True + except SMTPException: + flash('Mail to "{}" could not be sent!'.format(to_address)) + return False