diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 06a19a8..f8a6148 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -11,7 +11,7 @@ class AccountController < PublicController def login @user = User.new return unless request.post? - self.current_user = User.authenticate(params[:login], params[:password]) + self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if logged_in? if params[:remember_me] == "1" self.current_user.remember_me diff --git a/app/models/change_password.rb b/app/models/change_password.rb index 42c6e79..2647041 100644 --- a/app/models/change_password.rb +++ b/app/models/change_password.rb @@ -1,5 +1,14 @@ # TODO: send an e-mail with a hash code to the task after the ChangePassword is creatd -> override messages from #Task +class HumanName + def human_name + @name + end + def initialize(name) + @name = name + end +end + class ChangePassword < Task serialize :data, Hash @@ -7,6 +16,9 @@ class ChangePassword < Task self[:data] ||= {} end + self.columns_hash['login'] = HumanName.new _('Username') + self.columns_hash['email'] = HumanName.new _('e-Mail') + attr_accessor :login, :email, :password, :password_confirmation N_('ChangePassword|Login') N_('ChangePassword|Email') diff --git a/app/models/user.rb b/app/models/user.rb index 80a0e74..6dabb86 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,6 +7,14 @@ class User < ActiveRecord::Base N_('User|Password') N_('User|Password confirmation') + def self.human_attribute_name(attrib) + case attrib.to_sym + when :login: return _('Username') + when :email: return _('e-Mail') + else self.superclass.human_attribute_name(attrib) + end + end + before_create do |user| if user.environment.nil? user.environment = Environment.default diff --git a/app/views/account/forgot_password.rhtml b/app/views/account/forgot_password.rhtml index d17abe2..e020971 100644 --- a/app/views/account/forgot_password.rhtml +++ b/app/views/account/forgot_password.rhtml @@ -2,11 +2,15 @@ <%= error_messages_for :change_password %> -<%= help(_('To change your password, please fill the form on this screen using yout username and your e-mail. You will receive a message at that e-mail address with a web address you can access to create a new password.')) %> +<% labelled_form_for :change_password, @change_password, + :url => { :action => 'forgot_password' }, + :html => { :help => _('To change your password, please fill the form on this screen using your username and your e-mail. You will receive a message at that e-mail address with a web address you can access to create a new password.') } do |f| %> + + <%= f.text_field :login, + :onchange => 'this.value = convToValidLogin( this.value )' %> + + <%= f.text_field :email %> -<% form_for :change_password, @change_password, :url => { :action => 'forgot_password' } do |f| %> - <%= labelled_form_field(_('Username'), (f.text_field :login)) %> - <%= labelled_form_field(_('E-mail'), (f.text_field :email)) %>
<% button_bar do %> <%= submit_button('send', _('Send change password procedure by e-mail')) %> diff --git a/app/views/account/login.rhtml b/app/views/account/login.rhtml index 0d8f9d6..1a8db48 100644 --- a/app/views/account/login.rhtml +++ b/app/views/account/login.rhtml @@ -2,13 +2,20 @@

<%= _('Login') %>

-<% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %> +<% + @user = User.new if ! @user +%> -<%= display_form_field(_('Login'), - text_field_tag(:login, nil, - :onchange => 'this.value = convToValidLogin( this.value )') ) %> +<% labelled_form_for :user, @user, + :url => { :controller => 'account', :action => 'login' }, + :html => { :help => _('If you are a registered user, enter your username and password to be authenticated.')+'

'+_('To join on this environment, click on "I want to be an user!".')+'

'+_('If you forgot your password, click on "I forgot my password!" link.') } do |f| %> -<%= display_form_field(_('Password'), password_field_tag(:password) ) %> +<%= f.text_field :login, + :help => _('Here goes the nickname that you give on the registration.'), + :onchange => 'this.value = convToValidLogin( this.value )' %> + +<%= f.password_field :password, + :help => _('your password is personal, protect it.') %> <% button_bar do %> <%= submit_button( 'login', _('Log in') )%> @@ -17,11 +24,11 @@ <% end %> -

+

<%= link_to _("I forgot my password!"), :controller => 'account', :action => 'forgot_password' %>

-

+

<%= link_to _("I want to be an user!"), :controller => 'account', :action => 'signup' %>

diff --git a/app/views/account/login_block.rhtml b/app/views/account/login_block.rhtml index a321fc9..85b1ebd 100644 --- a/app/views/account/login_block.rhtml +++ b/app/views/account/login_block.rhtml @@ -4,25 +4,33 @@

<%= _('Login') %>

<%= javascript_include_tag 'show-mouse-help' %> + <%# + %> <%= javascript_include_tag 'noosfero-show-help' %> <%# javascript_tag('noosferoHelpInit(%s, %s)' % [ _('Do you want to activate the automatic help mode?').inspect, _('If needed, you can activate the automatic help mode by clicking the question mark symbol in the top-right corner').inspect ]) %> diff --git a/public/javascripts/noosfero-show-help.js b/public/javascripts/noosfero-show-help.js index 890007f..e09bdb8 100644 --- a/public/javascripts/noosfero-show-help.js +++ b/public/javascripts/noosfero-show-help.js @@ -8,8 +8,8 @@ function mouseHelpOnOff() { $("btShowHelp").className = "icon-help32off"; } var date = new Date(); - // open/close help on help button is remembed by 30 days: - date.setTime( date.getTime() + ( 30*24*60*60*1000 ) ); + // open/close help on help button is remembed by one year: + date.setTime( date.getTime() + ( 365*24*60*60*1000 ) ); var expires = "; expires=" + date.toGMTString(); document.cookie = "mouseHelpTurnOn="+ pageHelp.info.updateBox + expires +"; path=/"; } @@ -33,7 +33,9 @@ if ( document.cookie.indexOf("mouseHelpTurnOn=") > -1 ) { mouseHelpOnOff(); } } + +/* O Noosfero não deve mais propor o help na entrada else { new Effect.Appear( "noticeAboutHelp", {duration:2} ); } - +*/ -- libgit2 0.21.2