From 650888c73b734dc9e7bf9ce4a20cb05de68c45a1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 24 Sep 2007 18:38:45 +0000 Subject: [PATCH] Added a named route for the home page. git-svn-id: http://redmine.rubyforge.org/svn/trunk@760 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/account_controller.rb | 12 ++++++------ app/views/layouts/base.rhtml | 2 +- config/routes.rb | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 44e4cc2210..e8e70076bd 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -63,15 +63,15 @@ class AccountController < ApplicationController cookies.delete :autologin Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) if User.current.logged? self.logged_user = nil - redirect_to :controller => 'welcome' + redirect_to home_url end # Enable user to choose a new password def lost_password - redirect_to :controller => 'welcome' and return unless Setting.lost_password? + redirect_to(home_url) && return unless Setting.lost_password? if params[:token] @token = Token.find_by_action_and_value("recovery", params[:token]) - redirect_to :controller => 'welcome' and return unless @token and !@token.expired? + redirect_to(home_url) && return unless @token and !@token.expired? @user = @token.user if request.post? @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] @@ -105,12 +105,12 @@ class AccountController < ApplicationController # User self-registration def register - redirect_to :controller => 'welcome' and return unless Setting.self_registration? + redirect_to(home_url) && return unless Setting.self_registration? if params[:token] token = Token.find_by_action_and_value("register", params[:token]) - redirect_to :controller => 'welcome' and return unless token and !token.expired? + redirect_to(home_url) && return unless token and !token.expired? user = token.user - redirect_to :controller => 'welcome' and return unless user.status == User::STATUS_REGISTERED + redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED user.status = User::STATUS_ACTIVE if user.save token.destroy diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml index 12265d7cea..9bab2f6d9e 100644 --- a/app/views/layouts/base.rhtml +++ b/app/views/layouts/base.rhtml @@ -30,7 +30,7 @@ <%= link_to(l(:label_register), :controller => 'account',:action => 'register') if Setting.self_registration? %> <% end %> - <%= link_to l(:label_home), { :controller => 'welcome' } %> + <%= link_to l(:label_home), home_url %> <%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'} if User.current.logged? %> <%= link_to l(:label_project_plural), { :controller => 'projects' } %> <%= link_to l(:label_administration), { :controller => 'admin' } if User.current.admin? %> diff --git a/config/routes.rb b/config/routes.rb index a980f3f51e..62a74446fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,9 +6,7 @@ ActionController::Routing::Routes.draw do |map| # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action - # You can have the root of your site routed by hooking up '' - # -- just remember to delete public/index.html. - map.connect '', :controller => "welcome" + map.home '', :controller => 'welcome' map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'