module Hello::RailsController

Public Instance Methods

hello_manager() click to toggle source
# File lib/hello/rails_controller.rb, line 48
def hello_manager
  request.env['hello'] ||= Hello::RequestManager.create(request)
end
hello_store_url_on_session!() click to toggle source
# File lib/hello/rails_controller.rb, line 58
def hello_store_url_on_session!
  if hello_manager.stateful?
    session[:url] = url_for(params.permit!.merge(only_path: true))
  end
end
render_sudo_mode_form() click to toggle source
# File lib/hello/rails_controller.rb, line 77
def render_sudo_mode_form
  render 'hello/authentication/sudo_mode'
end
sign_up_disabled() click to toggle source
# File lib/hello/rails_controller.rb, line 54
def sign_up_disabled
  Hello.configuration.sign_up_disabled || action_name=='disabled'
end
sudo_mode() click to toggle source
# File lib/hello/rails_controller.rb, line 70
def sudo_mode
  unless sudo_mode?
    hello_store_url_on_session!
    render_sudo_mode_form
  end
end
sudo_mode?() click to toggle source
# File lib/hello/rails_controller.rb, line 66
def sudo_mode?
  current_access && current_access.sudo_expires_at.future?
end

Private Instance Methods

hello_around_action() { || ... } click to toggle source
# File lib/hello/rails_controller.rb, line 98
def hello_around_action(&block)
  use_locale(nil)

  if current_user
    # begin keep-alive
    Access.cached_destroy_all_expired
    current_access.keep_alive!
    expires_in = view_context.time_ago_in_words(current_access.expires_at)
    logger.info "  #{'Hello Session'.bold.light_blue} expires in #{expires_in}"
    # end keep-alive

    Time.use_zone(current_user.time_zone, &block)
  else
    yield
  end
end
restrict_by_role() click to toggle source
# File lib/hello/rails_controller.rb, line 85
def restrict_by_role
  @_hello_rbr ||= RestrictByRole.new(self)
end
use_locale(locale) click to toggle source
# File lib/hello/rails_controller.rb, line 90
def use_locale(locale)
  locale ||= current_user && current_user.locale
  locale ||= session['locale']
  locale ||= recommended_locale.to_s

  I18n.locale = session['locale'] = locale
end