diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f8e0b3d3a..27aba499f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -32,7 +32,7 @@ class ApplicationController < ActionController::Base if request.env['HTTP_USER_AGENT'].match(/mobile/i) root_path else - logged_out_path + new_user_session_path end end @@ -106,7 +106,7 @@ class ApplicationController < ActionController::Base end def after_sign_in_path_for(resource) - stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : stream_path) + stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : root_path) end def max_time diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 222e9fd35..b809e0c61 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,10 +3,13 @@ # the COPYRIGHT file. class HomeController < ApplicationController - def show if current_user - redirect_to stream_path if current_user + if(Role.is_beta?(current_user.person) || Role.is_admin?(current_user.person)) && current_user.contacts.receiving.count == 0 + redirect_to person_path(current_user.person.guid) + else + redirect_to stream_path + end elsif is_mobile_device? redirect_to user_session_path else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2c984ec5a..cfedda853 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,7 +6,7 @@ class UsersController < ApplicationController require File.join(Rails.root, 'lib/diaspora/exporter') require File.join(Rails.root, 'lib/collect_user_photos') - before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo, :logged_out] + before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo] respond_to :html @@ -120,13 +120,6 @@ class UsersController < ApplicationController render "users/getting_started" end - def logged_out - @page = :logged_out - if user_signed_in? - redirect_to stream_path - end - end - def getting_started_completed user = current_user user.update_attributes(:getting_started => false) diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index d0d8ce659..d71183ee8 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -63,7 +63,7 @@ module LayoutHelper end def include_base_css_framework(use_bootstrap=false) - if use_bootstrap || @aspect == :getting_started || @page == :logged_out || @page == :experimental + if use_bootstrap || @aspect == :getting_started || @page == :experimental stylesheet_link_tag 'bootstrap-complete' else stylesheet_link_tag 'blueprint', :media => 'screen' @@ -86,8 +86,6 @@ module LayoutHelper end def flash_messages - return if @page == :logged_out - flash.map do |name, msg| content_tag(:div, :id => "flash_#{name}") do content_tag(:div, msg, :class => 'message') diff --git a/app/models/role.rb b/app/models/role.rb index 57eb50d65..96f89ce54 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -6,6 +6,10 @@ class Role < ActiveRecord::Base find_by_person_id_and_name(person.id, 'admin') end + def self.is_beta?(person) + find_by_person_id_and_name(person.id, 'beta') + end + def self.add_beta(person) find_or_create_by_person_id_and_name(person.id, 'beta') end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3e2225d99..049dd2872 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -52,7 +52,7 @@ = render 'layouts/header' .container - - if @aspect == :getting_started || @page == :logged_out + - if @aspect == :getting_started = yield - else .span-24.last diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 4ea40e8b6..2005a3e14 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -997,13 +997,6 @@ en: activity: title: "My Activity" users: - logged_out: - signed_out: "You've signed out of Diaspora*" - go_mobile: "Now go mobile." - simply_visit: "Simply visit" - on_your_mobile_device: "on your mobile device to access Diaspora* mobile." - works_on_modern: "Works on all modern smartphones" - edit: export_data: "Export Data" photo_export_unavailable: "Photo exporting currently unavailable" diff --git a/config/routes.rb b/config/routes.rb index ad0e731ac..389b3c0e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -213,9 +213,6 @@ Diaspora::Application.routes.draw do mount Resque::Server.new, :at => '/resque-jobs', :as => "resque_web" end - # Logout Page (go mobile) - get 'logged_out' => 'users#logged_out', :as => 'logged_out' - # Startpage root :to => 'home#show' end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index f25cd4158..4640eff14 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -11,10 +11,28 @@ describe HomeController do response.should_not be_redirect end - it 'redirects to multis index if user is logged in' do - sign_in alice - get :show, :home => true - response.should redirect_to(stream_path) - end + context 'redirection' + before do + sign_in alice + end + + it 'points to the stream if a user has contacts' do + get :show, :home => true + response.should redirect_to(stream_path) + end + + it "points to a user's profile page if a user is an admin without contacts" do + alice.contacts.delete_all + Role.add_admin(alice.person) + get :show, :home => true + response.should redirect_to(person_path(alice.person)) + end + + it "points to the root_path if a user is an admin without contacts" do + alice.contacts.delete_all + Role.add_beta(alice.person) + get :show, :home => true + response.should redirect_to(person_path(alice.person)) + end end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index f1ff07342..108ddd19d 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -82,7 +82,7 @@ describe RegistrationsController do it "redirects to the home path" do get :create, @valid_params response.should be_redirect - response.location.should match /^#{stream_url}\??$/ + response.location.should match /^#{root_url}\??$/ end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 855f45180..fb8f53bd6 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -18,17 +18,17 @@ describe SessionsController do end describe "#create" do - it "redirects to /stream for a non-mobile user" do + it "redirects to root_path for a non-mobile user" do post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}} response.should be_redirect - response.location.should match /^#{stream_url}\??$/ + response.location.should match /^#{root_url}\??$/ end it "redirects to /stream for a mobile user" do @request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7' post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}} response.should be_redirect - response.location.should match /^#{stream_url}\??$/ + response.location.should match /^#{root_url}\??$/ end it 'queues up an update job' do @@ -46,7 +46,7 @@ describe SessionsController do end it "redirects to / for a non-mobile user" do delete :destroy - response.should redirect_to logged_out_path + response.should redirect_to new_user_session_path end it "redirects to / for a mobile user" do