correctly redirect for beta and admin users (profile vs stream homepages)
This commit is contained in:
parent
b3de5ccbbe
commit
bbd4ee5738
11 changed files with 42 additions and 36 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
= render 'layouts/header'
|
||||
|
||||
.container
|
||||
- if @aspect == :getting_started || @page == :logged_out
|
||||
- if @aspect == :getting_started
|
||||
= yield
|
||||
- else
|
||||
.span-24.last
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue