diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -5,17 +5,17 @@ before_filter :authenticate, :except => [:index, :login] before_filter :check_viewability, :except => [:index, :login] -# -# COMMENT OUT: filter in each action instead -# -# before_filter :verify_time_limit, :only => [:submit] + # COMMENTED OUT: filter in each action instead + # before_filter :verify_time_limit, :only => [:submit] verify :method => :post, :only => [:submit], :redirect_to => { :action => :index } -# COMMENT OUT, only need when having high load -# caches_action :index, :login + # COMMENT OUT: only need when having high load + # caches_action :index, :login + # NOTE: This method is not actually needed, 'config/routes.rb' has + # assigned action login as a default action. def index redirect_to :action => 'login' end @@ -25,9 +25,17 @@ reset_session flash[:notice] = saved_notice + # EXPERIMENT: + # Hide login if in single user mode and the url does not + # explicitly specify /login # - # These are for site administrator login - # + # logger.info "PATH: #{request.path}" + # if Configuration['system.single_user_mode'] and + # request.path!='/main/login' + # @hidelogin = true + # end + + # Site administrator login @countries = Country.find(:all, :include => :sites) @country_select = @countries.collect { |c| [c.name, c.id] } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -55,11 +55,11 @@ def confirm login = params[:login] key = params[:activation] - user = User.find_by_login(login) - if (user) and (user.verify_activation_key(key)) - if user.valid? # check uniquenss of email - user.activated = true - user.save + @user = User.find_by_login(login) + if (@user) and (@user.verify_activation_key(key)) + if @user.valid? # check uniquenss of email + @user.activated = true + @user.save @result = :successful else @result = :email_used diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -128,6 +128,7 @@ end def enough_time_interval_between_same_email_registrations + return if !self.new_record? open_user = User.find_by_email(self.email, :order => 'created_at DESC') if open_user and open_user.created_at and diff --git a/app/views/main/login.html.haml b/app/views/main/login.html.haml --- a/app/views/main/login.html.haml +++ b/app/views/main/login.html.haml @@ -8,26 +8,27 @@ %b= Configuration['ui.front.welcome_message'] %br/ -Please login to see the problem list. -%br/ -%br/ -- if flash[:notice] - %hr/ - %b= flash[:notice] - %hr/ +- if !@hidelogin + Please login to see the problem list. + %br/ + %br/ + + - if flash[:notice] + %hr/ + %b= flash[:notice] + %hr/ -%div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} - - form_tag :controller => 'login', :action => 'login' do - %table - %tr - %td{:align => "right"} Login: - %td= text_field_tag 'login' - %tr - %td{:align => "right"} Password: - %td= password_field_tag - = submit_tag 'Login' - + %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} + - form_tag :controller => 'login', :action => 'login' do + %table + %tr + %td{:align => "right"} Login: + %td= text_field_tag 'login' + %tr + %td{:align => "right"} Password: + %td= password_field_tag + = submit_tag 'Login' %br/ - if Configuration['system.online_registration'] diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -83,6 +83,7 @@ User.should_receive(:find_by_login). with(login). and_return(@john) + User.should_not_receive(:find_by_email) @john.should_receive(:valid?).and_return(true) @john.should_receive(:activated=).with(true) @john.should_receive(:save).and_return(true)