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)) %>
+
<%= link_to _("I forgot my password!"), :controller => 'account', :action => 'forgot_password' %>
-
+
<%= link_to _("I want to be an user!"), :controller => 'account', :action => 'signup' %>
@@ -21,6 +35,6 @@
<% end %>
<% button_bar do %>
- <%= submit_button('save', _('Sign up'), :cancel => {:action => 'index'}) %>
+ <%= submit_button('save', _('Sign up'), :cancel => {:action => 'index'}, :class => 'icon-menu-login') %>
<% end %>
<% end -%>
diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml
index 6b19eba..0a76698 100644
--- a/app/views/layouts/application.rhtml
+++ b/app/views/layouts/application.rhtml
@@ -110,7 +110,7 @@
<%= _('Help') %>
+ onclick="mouseHelpOnOff(); return false"><%= _('Help') %>
<%= _('Login') %>
<%= _('Register') %>
<%= error_messages_for :user %>
-<% labelled_form_for :user, @user do |f| -%>
-
+<% labelled_form_for :user, @user,
+ :html => { :help=>_('Fill all this fields to join in this environment.' +
+ 'If you forgot your password, do not create a new account,' +
+ ' click on the "I forgot my password!" link. ;-)')
+ } do |f| -%>
+
<%= f.text_field :login,
- :onchange => 'this.value = convToValidLogin( this.value )' %>
+ :help => help=_('"Username" is a simple nickname to recognize you on this environment.'),
+ :onchange => 'this.value = convToValidLogin( this.value )' %>
+<%= help %>
+
+<%= f.text_field :email,
+ :help => help=_('We\'ll send you an e-mail to validate your registration.') %>
+<%= help %>
+
+<%= f.password_field :password,
+ :help => help=_('Do not use a obviously password, but try some unforgettable word.') %>
+<%= help %>
-<%= f.text_field :email %>
-<%= f.password_field :password %>
-<%= f.password_field :password_confirmation %>
+<%= f.password_field :password_confirmation,
+ :help => help=_('We need to be sure that you wrote correctly your password.') %>
+<%= help %>
<% if @terms_of_use %>