Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix direct password edit #1038

Merged
merged 3 commits into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/sprinkles/admin/src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function create(Request $request, Response $response, $args)

// Load the request schema
$schema = new RequestSchema('schema://requests/user/create.yaml');
$schema->set('password.validators.length.min', $config['site.password.length.min']);
$schema->set('password.validators.length.max', $config['site.password.length.max']);
$schema->set('passwordc.validators.length.min', $config['site.password.length.min']);
$schema->set('passwordc.validators.length.max', $config['site.password.length.max']);

// Whitelist and set parameter defaults
$transformer = new RequestDataTransformer($schema);
Expand Down Expand Up @@ -621,6 +625,10 @@ public function getModalCreate(Request $request, Response $response, $args)

// Load validation rules
$schema = new RequestSchema('schema://requests/user/create.yaml');
$schema->set('password.validators.length.min', $config['site.password.length.min']);
$schema->set('password.validators.length.max', $config['site.password.length.max']);
$schema->set('passwordc.validators.length.min', $config['site.password.length.min']);
$schema->set('passwordc.validators.length.max', $config['site.password.length.max']);
$validator = new JqueryValidationAdapter($schema, $this->ci->translator);

return $this->ci->view->render($response, 'modals/user.html.twig', [
Expand Down Expand Up @@ -786,8 +794,8 @@ public function getModalEditPassword(Request $request, Response $response, $args

// Load validation rules
$schema = new RequestSchema('schema://requests/user/edit-password.yaml');
$schema->set('password.validators.length.min', $config['site.password.length.min']);
$schema->set('password.validators.length.max', $config['site.password.length.max']);
$schema->set('value.validators.length.min', $config['site.password.length.min']);
$schema->set('value.validators.length.max', $config['site.password.length.max']);
$schema->set('passwordc.validators.length.min', $config['site.password.length.min']);
$schema->set('passwordc.validators.length.max', $config['site.password.length.max']);
$validator = new JqueryValidationAdapter($schema, $this->ci->translator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<label>{{translate('PASSWORD')}}</label>
<div class="input-group">
<span class="input-group-addon"><i class="fas fa-key"></i></span>
<input type="password" class="form-control" name="password" autocomplete="off" value="" placeholder="{{translate('PASSWORD.BETWEEN', {min: 12, max: 50})}}">
<input type="password" class="form-control" name="{{ passwordFieldName|default('password') }}" autocomplete="off" value="" placeholder="{{translate('PASSWORD.BETWEEN', {min: site.password.length.min, max: site.password.length.max})}}">
</div>
</div>
<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="js-form-alerts">
</div>
<div class="row">
{% include "forms/partials/user-set-password.html.twig" %}
{% include "forms/partials/user-set-password.html.twig" with {'passwordFieldName':passwordFieldName} %}
</div>
<br>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% block modal_title %}{{translate("USER.ADMIN.CHANGE_PASSWORD")}}{% endblock %}

{% block modal_body %}
{% include "forms/user-set-password.html.twig" %}
{% include "forms/user-set-password.html.twig" with {'passwordFieldName': 'value'} %}
{% endblock %}