fix: use vmodel for confirm password widget input
since previously this did not work at all for butterball (vue3 + oruga) - although it was never clear why per se.. Refs: #1
This commit is contained in:
parent
993f066f2c
commit
7171c7fb06
|
@ -1,6 +1,7 @@
|
||||||
<div i18n:domain="deform" tal:omit-tag=""
|
<div i18n:domain="deform" tal:omit-tag=""
|
||||||
tal:define="oid oid|field.oid;
|
tal:define="oid oid|field.oid;
|
||||||
name name|field.name;
|
name name|field.name;
|
||||||
|
vmodel vmodel|'field_model_' + name;
|
||||||
css_class css_class|field.widget.css_class;
|
css_class css_class|field.widget.css_class;
|
||||||
style style|field.widget.style;">
|
style style|field.widget.style;">
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@
|
||||||
${field.start_mapping()}
|
${field.start_mapping()}
|
||||||
<b-input type="password"
|
<b-input type="password"
|
||||||
name="${name}"
|
name="${name}"
|
||||||
value="${field.widget.redisplay and cstruct or ''}"
|
v-model="${vmodel}"
|
||||||
tal:attributes="class string: form-control ${css_class or ''};
|
tal:attributes="class string: form-control ${css_class or ''};
|
||||||
style style;
|
style style;
|
||||||
attributes|field.widget.attributes|{};"
|
attributes|field.widget.attributes|{};"
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
</b-input>
|
</b-input>
|
||||||
<b-input type="password"
|
<b-input type="password"
|
||||||
name="${name}-confirm"
|
name="${name}-confirm"
|
||||||
value="${field.widget.redisplay and confirm or ''}"
|
|
||||||
tal:attributes="class string: form-control ${css_class or ''};
|
tal:attributes="class string: form-control ${css_class or ''};
|
||||||
style style;
|
style style;
|
||||||
confirm_attributes|field.widget.confirm_attributes|{};"
|
confirm_attributes|field.widget.confirm_attributes|{};"
|
||||||
|
|
|
@ -44,28 +44,6 @@ class UserLogin(colander.MappingSchema):
|
||||||
widget=dfwidget.PasswordWidget())
|
widget=dfwidget.PasswordWidget())
|
||||||
|
|
||||||
|
|
||||||
@colander.deferred
|
|
||||||
def current_password_correct(node, kw):
|
|
||||||
request = kw['request']
|
|
||||||
app = request.rattail_config.get_app()
|
|
||||||
auth = app.get_auth_handler()
|
|
||||||
user = kw['user']
|
|
||||||
def validate(node, value):
|
|
||||||
if not auth.authenticate_user(Session(), user.username, value):
|
|
||||||
raise colander.Invalid(node, "The password is incorrect")
|
|
||||||
return validate
|
|
||||||
|
|
||||||
|
|
||||||
class ChangePassword(colander.MappingSchema):
|
|
||||||
|
|
||||||
current_password = colander.SchemaNode(colander.String(),
|
|
||||||
widget=dfwidget.PasswordWidget(),
|
|
||||||
validator=current_password_correct)
|
|
||||||
|
|
||||||
new_password = colander.SchemaNode(colander.String(),
|
|
||||||
widget=dfwidget.CheckedPasswordWidget())
|
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationView(View):
|
class AuthenticationView(View):
|
||||||
|
|
||||||
def forbidden(self):
|
def forbidden(self):
|
||||||
|
@ -181,7 +159,23 @@ class AuthenticationView(View):
|
||||||
self.request.user))
|
self.request.user))
|
||||||
return self.redirect(self.request.get_referrer())
|
return self.redirect(self.request.get_referrer())
|
||||||
|
|
||||||
schema = ChangePassword().bind(user=self.request.user, request=self.request)
|
def check_user_password(node, value):
|
||||||
|
auth = self.app.get_auth_handler()
|
||||||
|
user = self.request.user
|
||||||
|
if not auth.check_user_password(user, value):
|
||||||
|
node.raise_invalid("The password is incorrect")
|
||||||
|
|
||||||
|
schema = colander.Schema()
|
||||||
|
|
||||||
|
schema.add(colander.SchemaNode(colander.String(),
|
||||||
|
name='current_password',
|
||||||
|
widget=dfwidget.PasswordWidget(),
|
||||||
|
validator=check_user_password))
|
||||||
|
|
||||||
|
schema.add(colander.SchemaNode(colander.String(),
|
||||||
|
name='new_password',
|
||||||
|
widget=dfwidget.CheckedPasswordWidget()))
|
||||||
|
|
||||||
form = forms.Form(schema=schema, request=self.request)
|
form = forms.Form(schema=schema, request=self.request)
|
||||||
if form.validate():
|
if form.validate():
|
||||||
auth = self.app.get_auth_handler()
|
auth = self.app.get_auth_handler()
|
||||||
|
|
Loading…
Reference in a new issue