Commit ab83d73d025dd73e3b8a3caf7ed7b192ffba9d6a

Authored by Caio SBA
1 parent de2fad9c

After activation, redirects to login page

app/controllers/public/account_controller.rb
... ... @@ -18,8 +18,13 @@ class AccountController < ApplicationController
18 18  
19 19 def activate
20 20 @user = User.find_by_activation_code(params[:activation_code]) if params[:activation_code]
21   - 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?")
22   - redirect_back_or_default(:controller => 'home')
  21 + if @user and @user.activate
  22 + session[:notice] = _("Your account has been activated, now you can log in!")
  23 + redirect_to :action => 'login', :userlogin => @user.login
  24 + else
  25 + session[:notice] = _("It looks like you're trying to activate an account. Perhaps have already activated this account?")
  26 + redirect_back_or_default(:controller => 'home')
  27 + end
23 28 end
24 29  
25 30 # action to perform login to the application
... ...
app/views/account/login.rhtml
... ... @@ -7,7 +7,7 @@
7 7  
8 8 <% labelled_form_for :user, @user, :url => login_url do |f| %>
9 9  
10   - <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )' %>
  10 + <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )', :value => params[:userlogin] %>
11 11  
12 12 <%= f.password_field :password %>
13 13  
... ...
test/functional/account_controller_test.rb
... ... @@ -692,6 +692,7 @@ class AccountControllerTest &lt; Test::Unit::TestCase
692 692 should 'activate user when activation code is present and correct' do
693 693 user = User.create! :login => 'testuser', :password => 'test123', :password_confirmation => 'test123', :email => 'test@test.org'
694 694 get :activate, :activation_code => user.activation_code
  695 + assert_redirected_to :action => :login, :userlogin => user.login
695 696 post :login, :user => {:login => 'testuser', :password => 'test123'}
696 697 assert_not_nil session[:user]
697 698 assert_redirected_to :controller => 'profile_editor', :profile => 'testuser'
... ...