Commit 45943ddee12407521b9e65965f04e0153a1a066d

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 44739fca
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Limit user password size at signup form

(correcoes_aderencia)

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -21,6 +21,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
21 21  
22 22 Proc::new do
23 23 content_tag(:div,
  24 + hidden_field_tag("user_password_menssage", _("Choose a password that you can remember easily. It must have at least 6 characters.")) +
24 25 required(labelled_form_field(
25 26 _('Secondary e-Mail'),
26 27 text_field(:user, :secondary_email, :id => 'secondary_email_field') +
... ...
public/mpog-user-validations.js
1   -function check_reactivate_account(value, input_object){
2   - jQuery.ajax({
3   - url : "/plugin/mpog_software/check_reactivate_account",
4   - type: "GET",
5   - data: { "email": value },
6   - success: function(response) {
7   - if( jQuery("#forgot_link").length == 0 )
8   - jQuery(input_object).parent().append(response);
9   - else
10   - jQuery("#forgot_link").html(response);
11   - },
12   - error: function(type, err, message) {
13   - console.log(type+" -- "+err+" -- "+message);
14   - }
15   - });
16   -}
  1 +(function(){
  2 + function set_initial_form_custom_data() {
  3 + jQuery('#profile_data_country').val("BR");
17 4  
18   -function put_brazil_based_on_email(){
19   - var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br'];
20   - var value = this.value;
21   - var input_object = this;
22   - var gov_suffix = false;
  5 + jQuery("#password-balloon").html(jQuery("#user_password_menssage").val());
  6 + }
23 7  
24   - suffixes.each(function(suffix){
25   - var has_suffix = new RegExp("(.*)"+suffix+"$", "i");
  8 + function check_reactivate_account(value, input_object){
  9 + jQuery.ajax({
  10 + url : "/plugin/mpog_software/check_reactivate_account",
  11 + type: "GET",
  12 + data: { "email": value },
  13 + success: function(response) {
  14 + if( jQuery("#forgot_link").length == 0 )
  15 + jQuery(input_object).parent().append(response);
  16 + else
  17 + jQuery("#forgot_link").html(response);
  18 + },
  19 + error: function(type, err, message) {
  20 + console.log(type+" -- "+err+" -- "+message);
  21 + }
  22 + });
  23 + }
26 24  
27   - if( has_suffix.test(value) ) {
28   - gov_suffix = true;
29   - jQuery("#profile_data_country").val("BR");
30   - }
31   - });
  25 + function put_brazil_based_on_email(){
  26 + var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br'];
  27 + var value = this.value;
  28 + var input_object = this;
  29 + var gov_suffix = false;
32 30  
33   - jQuery("#profile_data_country").find(':not(:selected)').css('display', (gov_suffix?'none':'block'));
  31 + suffixes.each(function(suffix){
  32 + var has_suffix = new RegExp("(.*)"+suffix+"$", "i");
34 33  
  34 + if( has_suffix.test(value) ) {
  35 + gov_suffix = true;
  36 + jQuery("#profile_data_country").val("BR");
  37 + }
  38 + });
35 39  
36   - check_reactivate_account(value, input_object)
37   -}
  40 + jQuery("#profile_data_country").find(':not(:selected)').css('display', (gov_suffix?'none':'block'));
38 41  
39   -function validate_email_format(){
40   - var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
  42 + check_reactivate_account(value, input_object)
  43 + }
41 44  
42   - if( this.value.length > 0 ) {
43   - if(correct_format_regex.test(this.value))
44   - this.className = "validated";
45   - else
46   - this.className = "invalid";
47   - } else
48   - this.className = "";
49   -}
  45 + function validate_email_format(){
  46 + var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
50 47  
  48 + if( this.value.length > 0 ) {
  49 + if(correct_format_regex.test(this.value))
  50 + this.className = "validated";
  51 + else
  52 + this.className = "invalid";
  53 + } else
  54 + this.className = "";
  55 + }
  56 +
  57 + function verify_user_password_size() {
  58 + if( this.value.length < 6 ) {
  59 + jQuery(this).switchClass("validated", "invalid");
  60 + } else {
  61 + jQuery(this).switchClass("invalid", "validated");
  62 + }
  63 + }
51 64  
52   -jQuery(document).ready(function(){
53   - jQuery('#secondary_email_field').blur(
54   - validate_email_format
55   - );
  65 + jQuery(document).ready(function(){
  66 + set_initial_form_custom_data();
56 67  
57   - jQuery('#profile_data_country').val("BR");
  68 + jQuery('#secondary_email_field').blur(
  69 + validate_email_format
  70 + );
58 71  
59   - jQuery("#user_email").blur(
60   - put_brazil_based_on_email
61   - );
  72 + jQuery("#user_email").blur(put_brazil_based_on_email);
62 73  
63   - jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); });
64   - jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); });
  74 + jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); });
  75 + jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); });
65 76  
66   -});
  77 + jQuery("#user_pw").blur(verify_user_password_size);
  78 + });
  79 +})();
67 80 \ No newline at end of file
... ...