Skip to content
Snippets Groups Projects
Commit 8ff79fdf authored by Mohammed Razem's avatar Mohammed Razem Committed by Rajab Natshah
Browse files

Issue #2924033 by Mohammed J. Razem: Changed [Varbase security] feature with...

Issue #2924033 by Mohammed J. Razem: Changed [Varbase security] feature with new password policy behavior
parent 9180dc0c
No related branches found
No related tags found
No related merge requests found
Showing with 47 additions and 29 deletions
......@@ -4,12 +4,9 @@
* @file
* Contains varbase_security.module.
*/
use Drupal\password_policy\Entity\PasswordPolicy;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\Entity\User;
use Drupal\Component\Utility\Crypt;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
* Implements hook_form_FORM_ID_alter() for user_form().
......@@ -17,6 +14,7 @@
function varbase_security_form_user_form_alter(&$form, &$form_state) {
if (\Drupal::moduleHandler()->moduleExists('password_policy')) {
if (isset($form['account']['password_policy_status'])) {
// Hide the password policy status table.
unset($form['account']['password_policy_status']);
}
}
......@@ -28,10 +26,32 @@ function varbase_security_form_user_form_alter(&$form, &$form_state) {
function varbase_security_element_info_alter(array &$types) {
if (\Drupal::moduleHandler()->moduleExists('password_policy')) {
if (isset($types['password_confirm'])) {
if (isset($types['password_confirm']['#process'][1])
&& $types['password_confirm']['#process'][1] == 'password_policy_check_constraints_password_confirm_process') {
unset($types['password_confirm']['#process'][1]);
if (isset($types['password_confirm']['#process'])) {
// Hide the password confirm process.
if ($key = array_search('password_policy_check_constraints_password_confirm_process', $types['password_confirm']['#process'])) {
unset($types['password_confirm']['#process'][$key]);
}
}
// Have the custom Varbase security user form process password confirm.
$types['password_confirm']['#process'][] = 'varbase_security_user_form_process_password_confirm';
}
}
}
/**
* Varbase Security element process handler for client-side password validation.
*
* This #process handler is automatically invoked for 'password_confirm' form
* elements to add the JavaScript and string translations for dynamic password
* validation.
*/
function varbase_security_user_form_process_password_confirm($element) {
// Get Drupal core user form process password confirm over the password.
$element = user_form_process_password_confirm($element);
// Update the too short message.
$element['#attached']['drupalSettings']['password']['tooShort'] = t('Make it at least 6 characters');
// TODO: Convert _password_policy_constraints_validate to change drupal core.
return $element;
}
......@@ -25,3 +25,6 @@
font-size: 13px;
padding: 15px 0 0;
}
#auth-box .user-form .form-control {
max-width: 100%;
}
......@@ -37,4 +37,10 @@
font-size: 13px;
padding: 15px 0 0;
}
.user-form {
.form-control {
max-width: 100%;
}
}
}
......@@ -9,7 +9,7 @@
{# Content #}
{% block content %}
<a id="main-content"></a>
<div class="col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
<div id="auth-box" class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
<div id="middle-part">
{{ page.content }}
</div>
......
......@@ -30,16 +30,6 @@
{{ page.content }}
</div>
<div id="bottom-part">
{% if not logged_in %}
<div class="login-link">
<a href="{{ path('user.login') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Login'|t }}</a>
</div>
{% endif %}
{% if not logged_in and not user_settings_register_admin_only %}
<div class="register-link">
<a href="{{ path('user.register') }}"><span class="icon glyphicon glyphicon-user" aria-hidden="true"></span> {{ 'Register a new account'|t }}</a>
</div>
{% endif %}
<div class="back-link">
<a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }} {{ site_name }}</a>
</div>
......
......@@ -25,3 +25,6 @@
font-size: 13px;
padding: 15px 0 0;
}
#auth-box .user-form .form-control {
max-width: 100%;
}
\ No newline at end of file
......@@ -37,4 +37,10 @@
font-size: 13px;
padding: 15px 0 0;
}
}
.user-form {
.form-control {
max-width: 100%;
}
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
{# Content #}
{% block content %}
<a id="main-content"></a>
<div class="col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
<div id="auth-box" class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
<div id="middle-part">
{{ page.content }}
</div>
......
......@@ -30,16 +30,6 @@
{{ page.content }}
</div>
<div id="bottom-part">
{% if not logged_in %}
<div class="login-link">
<a href="{{ path('user.login') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Login'|t }}</a>
</div>
{% endif %}
{% if not logged_in and not user_settings_register_admin_only %}
<div class="register-link">
<a href="{{ path('user.register') }}"><span class="icon glyphicon glyphicon-user" aria-hidden="true"></span> {{ 'Register a new account'|t }}</a>
</div>
{% endif %}
<div class="back-link">
<a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }} {{ site_name }}</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment