Signed in users are now redirected to main page if they try to access root (#1726)
This commit is contained in:
parent
9cf7e53c99
commit
737d39dce9
|
@ -182,6 +182,14 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
helper_method :shared_access_allowed
|
||||
|
||||
# Returns the page that the logo redirects to when clicked on
|
||||
def home_page
|
||||
return admins_path if current_user.has_role? :super_admin
|
||||
return current_user.main_room if current_user.role.get_permission("can_create_rooms")
|
||||
cant_create_rooms_path
|
||||
end
|
||||
helper_method :home_page
|
||||
|
||||
# Parses the url for the user domain
|
||||
def parse_user_domain(hostname)
|
||||
return hostname.split('.').first if Rails.configuration.url_host.empty?
|
||||
|
|
|
@ -22,5 +22,7 @@ class MainController < ApplicationController
|
|||
def index
|
||||
# Store invite token
|
||||
session[:invite_token] = params[:invite_token] if params[:invite_token] && invite_registration
|
||||
|
||||
redirect_to home_page if current_user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,13 +55,6 @@ module ApplicationHelper
|
|||
@fallback_translations[I18n.default_locale]
|
||||
end
|
||||
|
||||
# Returns the page that the logo redirects to when clicked on
|
||||
def home_page
|
||||
return admins_path if current_user.has_role? :super_admin
|
||||
return current_user.main_room if current_user.role.get_permission("can_create_rooms")
|
||||
cant_create_rooms_path
|
||||
end
|
||||
|
||||
# Returns 'active' if the current page is the users home page (used to style header)
|
||||
def active_home
|
||||
home_actions = %w[show cant_create_rooms]
|
||||
|
|
|
@ -24,5 +24,14 @@ describe MainController, type: :controller do
|
|||
get :index
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "redirects signed in user to their home page" do
|
||||
user = create(:user)
|
||||
@request.session[:user_id] = user.id
|
||||
|
||||
get :index
|
||||
|
||||
expect(response).to redirect_to(user.main_room)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in New Issue