Fix change password form

Make fields required.
Adapt fields to the attribute aria-describedby.
pull/3306/head
Evghenii Barhatov 9 years ago
parent 930bfc9855
commit 57b4127d1c
  1. 1
      app/assets/javascripts/application.js.erb
  2. 16
      app/assets/javascripts/change_password.js
  3. 6
      app/helpers/password_helper.rb
  4. 14
      app/views/my/_password_form_fields.html.erb
  5. 4
      app/views/my/password.html.erb
  6. 4
      config/locales/en.yml

@ -63,7 +63,6 @@
//= require search
//= require colors
//= require tooltips
//= require change_password
//source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse
if (typeof []._reverse == 'undefined') {

@ -1,16 +0,0 @@
jQuery(function($) {
$('#new_password_confirmation, #new_password, #password').keyup(function() {
var passwordPresent = $('#password').val().length > 0;
var button = $('input[name="commit"]');
var newPass = $('#new_password').val();
var newPassConfirm = $('#new_password_confirmation').val();
var newPasswordsMatches = newPass === newPassConfirm;
var newPasswordsPresent = (newPass.length > 0) && (newPassConfirm.length > 0);
if (passwordPresent && newPasswordsMatches && newPasswordsPresent) {
button.removeAttr('disabled');
} else {
button.attr('disabled','disabled');
}
});
});

@ -31,10 +31,10 @@ module PasswordHelper
def render_password_complexity_tooltip
rules = password_rules_description
s = content_tag(:p, OpenProject::Passwords::Evaluator.min_length_description)
s += rules.capitalize.html_safe if rules.present?
s = OpenProject::Passwords::Evaluator.min_length_description
s += "<br> #{rules}" if rules.present?
s
s.html_safe
end
private

@ -11,19 +11,19 @@
<div class="form--field">
<%= styled_label_tag 'password', User.human_attribute_name(:password) %>
<%= styled_label_tag 'password', User.human_attribute_name(:password), class: '-required' %>
<div class="form--field-container">
<%= styled_password_field_tag 'password', nil, :size => 25 %>
<%= styled_password_field_tag 'password', nil, :size => 25, required: true %>
</div>
</div>
<div class="form--field">
<%= styled_label_tag 'new_password', User.human_attribute_name(:new_password) %>
<div class="form--field" style="padding-top: 1em">
<%= styled_label_tag 'new_password', User.human_attribute_name(:new_password), class: '-required' %>
<div class="form--field-container">
<%= styled_password_field_tag 'new_password', nil, :size => 25,
'aria-describedby' => 'new_password_tooltip',
'aria-describedby' => 'new_password_tooltip', required: true,
class: 'advanced-tooltip-trigger'%>
</div>
<div class="advanced-tooltip-content" id="new_password_tooltip">
@ -35,9 +35,9 @@
<div class="form--field">
<%= styled_label_tag 'new_password_confirmation',
User.human_attribute_name(:password_confirmation) %>
User.human_attribute_name(:password_confirmation), class: '-required' %>
<div class="form--field-container">
<%= styled_password_field_tag 'new_password_confirmation', nil,
<%= styled_password_field_tag 'new_password_confirmation', nil, required: true,
'aria-describedby' => 'confirm_password_tooltip',
:size => 25, class: 'advanced-tooltip-trigger' %>
</div>

@ -30,8 +30,8 @@ See doc/COPYRIGHT.rdoc for more details.
<%= toolbar title: l(:button_change_password) %>
<%= error_messages_for 'user' %>
<%= styled_form_tag({:action => :change_password},
{:autocomplete => 'off', class: 'form -wide-labels'}) do %>
<%= styled_form_tag({ action: :change_password },
{ autocomplete: 'off', class: 'form -wide-labels' }) do %>
<%= back_url_hidden_field_tag %>
<div class="grid-block medium-up-2">
<div class="grid-content" style="padding-left: 0">

@ -249,7 +249,7 @@ en:
user:
attributes:
password:
weak: "must contain characters of the following classes (at least %{min_count} of %{all_count}): %{rules}"
weak: "Must contain characters of the following classes (at least %{min_count} of %{all_count}): %{rules}"
lowercase: "lowercase (e.g. 'a')"
uppercase: "uppercase (e.g. 'A')"
numeric: "numeric (e.g. '1')"
@ -259,7 +259,7 @@ en:
other: "has been used before. Please choose one that is different from your last %{count}."
match:
confirm: "Confirm new password."
description: "Password should match with the one you have typed in New password field."
description: "'Password confirmation' should match the input in the 'New password' field."
member:
principal_blank: "Please choose at least one user or group."
role_blank: "Please choose at least one role."

Loading…
Cancel
Save