#2256 typo bugfix + new dispatcher index action according to rules specified

pull/2607/head
Kartones 10 years ago
parent 151cd3829a
commit 1bc597e857

@ -16,11 +16,25 @@ class Admin::PagesController < ApplicationController
ssl_required :common_data, :public, :datasets
before_filter :login_required, :except => [:public, :datasets, :sitemap]
before_filter :login_required, :except => [:public, :datasets, :sitemap, :index]
before_filter :belongs_to_organization
skip_before_filter :browser_is_html5_compliant?, only: [:public, :datasets]
skip_before_filter :ensure_user_organization_valid, only: [:public]
# Just an entrypoint to dispatch to different places according to
def index
# username.cartodb.com should redirect to the user dashboard in the maps view if the user is logged in
if !current_user.nil? && !current_viewer.nil? && current_user.id == current_viewer.id
redirect_to dashboard_url
# username.cartodb.com should redirect to the public user dashboard in the maps view if the username is not the user's username
elsif !current_viewer.nil? # Asummes either current_user nil or at least different from current_viewer
redirect_to public_maps_home_url
# username.cartodb.com should redirect to the public user dashboard in the maps view if the user is not logged in
else
redirect_to public_maps_home_url
end
end
def sitemap
username = CartoDB.extract_subdomain(request)
viewed_user = User.where(username: username.strip.downcase).first
@ -34,7 +48,7 @@ class Admin::PagesController < ApplicationController
# Redirect to org url if has only user
if viewed_user.has_organization?
if CartoDB.extract_real_subdomain(request) != viewed_user.organization.name
redirect_to CartoDB.base_url(viewed_user.organization.name) << public_sitemap_pathand and return
redirect_to CartoDB.base_url(viewed_user.organization.name) << public_sitemap_path and return
end
end

@ -7,7 +7,7 @@
CartoDB::Application.routes.draw do
# Double use: for user public dashboard AND org dashboard
root :to => 'admin/pages#public'
root :to => 'admin/pages#index'
get '(/u/:user_domain)/login' => 'sessions#new', as: :login
get '(/u/:user_domain)/logout' => 'sessions#destroy', as: :logout
@ -39,7 +39,7 @@ CartoDB::Application.routes.draw do
delete '(/u/:user_domain)/organization/users/:id' => 'organization_users#destroy', as: :delete_organization_user, constraints: { id: /[0-z\.\-]+/ }
get '(/u/:user_domain)/organization/users/new' => 'organization_users#new', as: :new_organization_user
# New user profile and account pages
# User profile and account pages
get '(/u/:user_domain)/profile' => 'users#profile', as: :profile_user
put '(/u/:user_domain)/profile' => 'users#profile_update', as: :profile_update_user
get '(/u/:user_domain)/account' => 'users#account', as: :account_user
@ -216,6 +216,7 @@ CartoDB::Application.routes.draw do
# Public dashboard
# root also goes to 'pages#public', as: public_visualizations_home
get '(/u/:user_domain)/maps' => 'pages#public', as: :public_maps_home
get '(/u/:user_domain)/page/:page' => 'pages#public', as: :public_page
get '(/u/:user_domain(/page/:page))' => 'pages#public', as: :public_page_alt
get '(/u/:user_domain)/tag/:tag' => 'pages#public', as: :public_tag

Loading…
Cancel
Save