Skip to content

Commit dbb87f9

Browse files
committed
Add force-password-change checkbox to user form
1 parent a05c938 commit dbb87f9

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/controllers/users_controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def create_or_update_resources(self, resource, form, session):
115115
user.email = form.email.data
116116
if form.password.data:
117117
user.set_password(form.password.data)
118+
user.force_password_change = form.force_password_change.data
118119
user.failed_sign_in_count = form.failed_sign_in_count.data or 0
119120

120121
totp_enabled = self.handler().config().get(

src/forms/user_form.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from flask_wtf import FlaskForm
22
from wtforms import FormField, IntegerField, SelectField, SelectMultipleField, \
3-
StringField, SubmitField, TextAreaField, ValidationError, PasswordField
3+
StringField, SubmitField, TextAreaField, ValidationError, PasswordField, \
4+
BooleanField
45
from wtforms.validators import DataRequired, Optional, Email, EqualTo, \
56
Length, NumberRange
67
from wtforms.widgets import NumberInput
@@ -21,6 +22,7 @@ class UserForm(FlaskForm):
2122
password = PasswordField(i18n('interface.users.form_password'))
2223
password2 = PasswordField(
2324
i18n('interface.users.form_password_repeat'), validators=[EqualTo('password')])
25+
force_password_change = BooleanField(i18n('interface.users.force_password_change'))
2426
totp_enabled = False
2527
totp_secret = StringField(
2628
i18n('interface.users.form_totp'), validators=[Optional(), Length(max=128)]

src/templates/users/form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ <h1>{{ title }}</h1>
5050
<legend>{{ i18n('interface.users.authentication') }}</legend>
5151
{{ wtf.render_field(form.password, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
5252
{{ wtf.render_field(form.password2, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
53+
{{ wtf.render_field(form.force_password_change, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
5354
{% if form.totp_enabled %}
5455
{{ wtf.render_field(form.totp_secret, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
5556
{% endif %}

0 commit comments

Comments
 (0)