diff --git a/app/views/account/_signup_form.rhtml b/app/views/account/_signup_form.rhtml
index 9a91453..bd522c8 100644
--- a/app/views/account/_signup_form.rhtml
+++ b/app/views/account/_signup_form.rhtml
@@ -7,6 +7,8 @@
<% @profile_data = @person %>
+<%= javascript_include_tag('sign_up_password_rate') %>
+
<%= error_messages_for :user, :person, :header_message => _('The account could not be created') %>
<% labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form', :honeypot => true } do |f| %>
@@ -52,7 +54,20 @@
<%= required f.password_field(:password, :id => 'user_pw') %>
<%= content_tag(:small,_('Choose a password that you can remember easily. It must have at least 4 characters.'), :id => 'password-balloon') %>
-
+
+
+ <%=_('Short') %>
+
+
+ <%=_('Bad') %>
+
+
+ <%=_('Good') %>
+
+
+ <%=_('Strong') %>
+
+
@@ -182,4 +197,5 @@ jQuery(function($) {
else $(this).addClass('validated');
});
});
+
diff --git a/public/javascripts/sign_up_password_rate.js b/public/javascripts/sign_up_password_rate.js
new file mode 100644
index 0000000..fba6204
--- /dev/null
+++ b/public/javascripts/sign_up_password_rate.js
@@ -0,0 +1,113 @@
+// This jQuery plugin is written by firas kassem [2007.04.05] and was modified to fit noosfero
+// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com
+// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
+
+var shortPass = 0
+var badPass = 1
+var goodPass = 2
+var strongPass = 3
+
+
+function passwordStrength(password,username)
+{
+ score = 0
+
+ //password < 4
+ if (password.length < 4 ) { return shortPass }
+
+ //password == username
+ if (password.toLowerCase()==username.toLowerCase()) badPass
+
+ //password length
+ score += password.length * 4
+ score += ( checkRepetition(1,password).length - password.length ) * 1
+ score += ( checkRepetition(2,password).length - password.length ) * 1
+ score += ( checkRepetition(3,password).length - password.length ) * 1
+ score += ( checkRepetition(4,password).length - password.length ) * 1
+
+ //password has 3 numbers
+ if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5
+
+ //password has 2 sybols
+ if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5
+
+ //password has Upper and Lower chars
+ if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10
+
+ //password has number and chars
+ if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15
+ //
+ //password has number and symbol
+ if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15
+
+ //password has char and symbol
+ if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15
+
+ //password is just a nubers or chars
+ if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10
+
+ //verifing 0 < score < 100
+ if ( score < 0 ) score = 0
+ if ( score > 100 ) score = 100
+
+ if (score < 34 ) return badPass
+ if (score < 68 ) return goodPass
+ return strongPass
+}
+
+function checkRepetition(pLen,str)
+{
+ res = ""
+ for ( i=0; i