From ab83d73d025dd73e3b8a3caf7ed7b192ffba9d6a Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Fri, 30 Sep 2011 01:54:07 -0300 Subject: [PATCH] After activation, redirects to login page --- app/controllers/public/account_controller.rb | 9 +++++++-- app/views/account/login.rhtml | 2 +- test/functional/account_controller_test.rb | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 39e772d..a8458b9 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -18,8 +18,13 @@ class AccountController < ApplicationController def activate @user = User.find_by_activation_code(params[:activation_code]) if params[:activation_code] - session[:notice] = (@user and @user.activate) ? _("Your account has been activated, now you can log in!") : _("It looks like you're trying to activate an account. Perhaps have already activated this account?") - redirect_back_or_default(:controller => 'home') + if @user and @user.activate + session[:notice] = _("Your account has been activated, now you can log in!") + redirect_to :action => 'login', :userlogin => @user.login + else + session[:notice] = _("It looks like you're trying to activate an account. Perhaps have already activated this account?") + redirect_back_or_default(:controller => 'home') + end end # action to perform login to the application diff --git a/app/views/account/login.rhtml b/app/views/account/login.rhtml index ac98f5a..3e8bf97 100644 --- a/app/views/account/login.rhtml +++ b/app/views/account/login.rhtml @@ -7,7 +7,7 @@ <% labelled_form_for :user, @user, :url => login_url do |f| %> - <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )' %> + <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )', :value => params[:userlogin] %> <%= f.password_field :password %> diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index baa627d..e7e32e7 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -692,6 +692,7 @@ class AccountControllerTest < Test::Unit::TestCase should 'activate user when activation code is present and correct' do user = User.create! :login => 'testuser', :password => 'test123', :password_confirmation => 'test123', :email => 'test@test.org' get :activate, :activation_code => user.activation_code + assert_redirected_to :action => :login, :userlogin => user.login post :login, :user => {:login => 'testuser', :password => 'test123'} assert_not_nil session[:user] assert_redirected_to :controller => 'profile_editor', :profile => 'testuser' -- libgit2 0.21.2