Class: ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ApplicationController
- Includes:
- FlashTruncation, Sequencescape::Api::Rails::ApplicationController, SessionHelper
- Defined in:
- app/controllers/application_controller.rb
Overview
Base controller for application Sets up:
-
v1 api support
-
Sequencescape::Api::Rails::ApplicationController imports settings from #api_connection_options
-
session validation on #check_for_current_user!
Direct Known Subclasses
CreationController, ExportsController, HealthController, LabwareController, PipelineWorkInProgressController, PipelinesController, Plates::WorkCompletionsController, PrintJobsController, QcFilesController, RobotsController, SearchController, SequencescapeSubmissionsController, SessionsController, TagPlatesController, Tubes::TubesExportsController, Tubes::ValidatePairedTubesController, Tubes::WorkCompletionsController
Instance Method Summary collapse
- #api_connection_options ⇒ Object
- #check_for_current_user! ⇒ Object
- #check_for_login! ⇒ Object included from SessionHelper
- #current_user_uuid ⇒ Object included from SessionHelper
- #logged_in? ⇒ Boolean included from SessionHelper
-
#logged_in_class ⇒ Object
included
from SessionHelper
Toggle class if user is logged in.
-
#max_flash_size ⇒ Object
included
from FlashTruncation
The maximum cookie size is 4096 bytes, however this is post-encryption, which increases the size.
- #session_switcher ⇒ Object included from SessionHelper
-
#truncate_flash(message, max_size = max_flash_size) ⇒ Array, String
included
from FlashTruncation
Truncates the flash message to avoid an ActionDispatch::Cookies::CookieOverflow.
-
#truncate_flash_array(array, max_size = max_flash_size) ⇒ Array
included
from FlashTruncation
Handles truncation of arrays passed to the flash.
-
#user_name ⇒ Object
included
from SessionHelper
Returns the name of the logged in user.
Instance Method Details
#api_connection_options ⇒ Object
15 16 17 |
# File 'app/controllers/application_controller.rb', line 15 def Limber::Application.config.api.v1..dup end |
#check_for_current_user! ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/application_controller.rb', line 21 def check_for_current_user! return true if current_user_uuid.present? redirect_to( search_path, alert: 'You must be logged in to do that. Performing actions in multiple tabs can log you out.' # rubocop:todo Rails/I18nLocaleTexts ) end |
#check_for_login! ⇒ Object Originally defined in module SessionHelper
#current_user_uuid ⇒ Object Originally defined in module SessionHelper
#logged_in? ⇒ Boolean Originally defined in module SessionHelper
#logged_in_class ⇒ Object Originally defined in module SessionHelper
Toggle class if user is logged in. This is applied to the body, so you shouldn’t need to add it to other elements
#max_flash_size ⇒ Object Originally defined in module FlashTruncation
The maximum cookie size is 4096 bytes, however this is post-encryption, which increases the size. The value of 2048 was obtained by mapping the size of encrypted strings. In practice 2255 bytes was the largest size, but I rounded down to 2kb to provide a bit of overhead for array serialization, additional flash information to and allow for slight implementation changes.
#session_switcher ⇒ Object Originally defined in module SessionHelper
#truncate_flash(message, max_size = max_flash_size) ⇒ Array, String Originally defined in module FlashTruncation
Truncates the flash message to avoid an ActionDispatch::Cookies::CookieOverflow. Maximum cookie size is checked against ActionDispatch::Cookies::MAX_COOKIE_SIZE which is 4096 bytes; however:
-
This is the size of the session cookie post encryption, which inflates the size
-
This cookie also needs to contain other data, such as the session_id, user_uuid and user_name
#truncate_flash_array(array, max_size = max_flash_size) ⇒ Array Originally defined in module FlashTruncation
Handles truncation of arrays passed to the flash. This is not intended to be used directly, instead use truncate_flash.
#user_name ⇒ Object Originally defined in module SessionHelper
Returns the name of the logged in user. Returns guest if no one is logged in.