Commit 72324796b8bf7326faf5079790f14e9291365c44
1 parent
adfbbf1b
Exists in
master
and in
22 other branches
ActionItem232: now any text will be converted on a valid login name on login fields
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1573 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
23 additions
and
3 deletions
Show diff stats
app/views/account/login.rhtml
@@ -4,7 +4,9 @@ | @@ -4,7 +4,9 @@ | ||
4 | 4 | ||
5 | <% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %> | 5 | <% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %> |
6 | 6 | ||
7 | -<%= display_form_field(_('Login'), text_field_tag(:login) ) %> | 7 | +<%= display_form_field(_('Login'), |
8 | + text_field_tag(:login, nil, | ||
9 | + :onchange => 'this.value = convToValidLogin( this.value )') ) %> | ||
8 | 10 | ||
9 | <%= display_form_field(_('Password'), password_field_tag(:password) ) %> | 11 | <%= display_form_field(_('Password'), password_field_tag(:password) ) %> |
10 | 12 |
app/views/account/login_block.rhtml
@@ -8,7 +8,9 @@ | @@ -8,7 +8,9 @@ | ||
8 | <% labelled_form_for :user, @user, | 8 | <% labelled_form_for :user, @user, |
9 | :url => { :controller => 'account', :action => 'login' } do |f| %> | 9 | :url => { :controller => 'account', :action => 'login' } do |f| %> |
10 | 10 | ||
11 | - <%= display_form_field(_('Username'), text_field_tag(:login) ) %> | 11 | + <%= display_form_field(_('Username'), |
12 | + text_field_tag(:login, nil, | ||
13 | + :onchange => 'this.value = convToValidLogin( this.value )') ) %> | ||
12 | <%= display_form_field(_('Password'), password_field_tag(:password) ) %> | 14 | <%= display_form_field(_('Password'), password_field_tag(:password) ) %> |
13 | 15 | ||
14 | <% button_bar do %> | 16 | <% button_bar do %> |
app/views/account/signup.rhtml
@@ -3,7 +3,9 @@ | @@ -3,7 +3,9 @@ | ||
3 | <%= error_messages_for :user %> | 3 | <%= error_messages_for :user %> |
4 | <% labelled_form_for :user, @user do |f| -%> | 4 | <% labelled_form_for :user, @user do |f| -%> |
5 | 5 | ||
6 | -<%= f.text_field :login %> | 6 | +<%= f.text_field :login, |
7 | + :onchange => 'this.value = convToValidLogin( this.value )' %> | ||
8 | + | ||
7 | <%= f.text_field :email %> | 9 | <%= f.text_field :email %> |
8 | <%= f.password_field :password %> | 10 | <%= f.password_field :password %> |
9 | <%= f.password_field :password_confirmation %> | 11 | <%= f.password_field :password_confirmation %> |
945 Bytes
1.53 KB
public/javascripts/application.js
@@ -25,6 +25,20 @@ function focus_first_field() { | @@ -25,6 +25,20 @@ function focus_first_field() { | ||
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | +/* * * Convert a string to a valid login name * * */ | ||
29 | +function convToValidLogin( str ) { | ||
30 | + return str.toLowerCase() | ||
31 | + .replace( /á|à|ã|â/g, "a" ) | ||
32 | + .replace( /é|ê/g, "e" ) | ||
33 | + .replace( /í/g, "i" ) | ||
34 | + .replace( /ó|ô|õ|ö/g, "o" ) | ||
35 | + .replace( /ú|ũ|ü/g, "u" ) | ||
36 | + .replace( /ñ/g, "n" ) | ||
37 | + .replace( /ç/g, "c" ) | ||
38 | + .replace( /[^-_a-z0-9]+/g, "" ) | ||
39 | +} | ||
40 | + | ||
41 | + | ||
28 | /* * * Template Box Size Help * * */ | 42 | /* * * Template Box Size Help * * */ |
29 | function resizePrincipalTemplateBox() { | 43 | function resizePrincipalTemplateBox() { |
30 | var box1 = $$( "div.box-1" )[0]; | 44 | var box1 = $$( "div.box-1" )[0]; |