Files
nairobi/app/controllers/users/sessions_controller.rb
taitus a5911f5c6a Modify admin layout to only manage tenants and admins
We only want to render the account link and login items in the header.
And we want only render the Multitenancy and Administrators sections in
the admin sidebar.

We include the administrators management so it's possible to give
permissions to other users to manage tenants.

In order to restrict access to other sections by typing the URL or
following a link, we're only enabling the rest of the routes when we
aren't in the multitenancy management mode.
2024-11-06 11:17:53 +01:00

30 lines
768 B
Ruby

class Users::SessionsController < Devise::SessionsController
def destroy
@stored_location = stored_location_for(:user)
super
end
private
def after_sign_in_path_for(resource)
if Rails.application.multitenancy_management_mode? && !resource.administrator?
account_path
elsif !verifying_via_email? && resource.show_welcome_screen?
welcome_path
else
super
end
end
def after_sign_out_path_for(resource)
@stored_location.present? && !@stored_location.match("management") ? @stored_location : super
end
def verifying_via_email?
return false if resource.blank?
stored_path = session[stored_location_key_for(resource)] || ""
stored_path[0..5] == "/email"
end
end