abstract class BrowserAction

Included Modules

Direct Known Subclasses

Defined in:

actions/browser_action.cr

Constant Summary

ACCEPTED_FORMAT_SYMBOLS = [:html, :json]
AFTER_PIPES = [set_previous_page_url] of Symbol
BEFORE_PIPES = [verify_accepted_format, protect_from_forgery, disable_caching, require_logged_in, require_logged_out, pin_login_to_ip_address, enforce_login_idle_timeout, check_authorization, set_frame_guard_header, set_sniff_guard_header, set_xss_guard_header] of Symbol
EXPOSURES = [] of Symbol
PARAM_DECLARATIONS = [] of Crystal::Macros::TypeDeclaration
ROUTE_SETTINGS = {prefix: ""}
SKIPPED_PIPES = [pin_login_to_ip_address] of Symbol

Class Method Summary

Macro Summary

Instance Method Summary

Class Method Detail

def self._accepted_formats : Array(Symbol) #

[View source]

Macro Detail

macro authorize(&block) #

[View source]
macro authorize_user(&block) #

[View source]

Instance Method Detail

def authorize?(__arg0 : Shield::User) : Bool | Nil #

[View source]
def authorize? : Bool | Nil #

def check_authorization #

[View source]
def current_login #

[View source]
def current_login? : Login | Nil #

def current_user #

[View source]
def current_user? : User | Nil #

def disable_caching #

[View source]
def do_check_authorization_failed #

[View source]
def do_enforce_login_idle_timeout_failed #

[View source]
def do_pin_email_confirmation_to_ip_address_failed #

[View source]
def do_pin_login_to_ip_address_failed #

[View source]
def do_pin_password_reset_to_ip_address_failed #

[View source]
def do_require_logged_in_failed #

[View source]
def do_require_logged_out_failed #

[View source]
def enforce_login_idle_timeout #

[View source]
def frame_guard_value : String #

[View source]
def logged_in? : Bool #

[View source]
def logged_out? : Bool #

[View source]
def paginator_per_page : Int32 #
Description copied from module Lucky::Paginator::BackendHelpers

The number of records to display per page. Defaults to 25

You can override this in your actions

Example

abstract class BrowserAction < Lucky::Action
  include Lucky::Paginator::BackendHelpers

  # Set to a new static value
  def paginator_per_page : Int32
    50 # defaults to 25
  end

  # Or you could allow setting the number from a param
  def paginator_per_page : Int32
    params.get?(:per_page).try(&.to_i) || 25
  end
end

[View source]
def pin_email_confirmation_to_ip_address #

[View source]
def pin_login_to_ip_address #

[View source]
def pin_password_reset_to_ip_address #

[View source]
def previous_page_url #

def previous_page_url? : String | Nil #

def redirect_back(*, fallback : Lucky::Action.class, status : HTTP::Status, allow_external = false) #

def redirect_back(*, fallback : Lucky::RouteHelper, status : HTTP::Status, allow_external = false) #

def redirect_back(*, fallback : String, status : Int32 = 302, allow_external : Bool = false) #
Description copied from module Lucky::Redirectable

Redirects the browser to the page that issued the request (the referrer) if possible, otherwise redirects to the provided default fallback location.

The referrer information is pulled from the 'Referer' header on the request. This is an optional header, and if the request is missing this header the fallback will be used.

redirect_back fallback: "/users"

A redirect status can be specified

redirect_back fallback: "/home", status: 301

External referrers are ignored by default. It is determined by comparing the referer header to the request host. They can be explicitly allowed if necessary

redirect_back fallback: "/home", allow_external: true

If the referer path matches the current request path, the fallback will be used to avoid redirecting back to the same page.


def remote_ip : Socket::IPAddress #

def remote_ip? : Socket::IPAddress | Nil #

def require_logged_in #

[View source]
def require_logged_out #

[View source]
def return_url #

def return_url? : String | Nil #

def set_no_referrer_policy #

[View source]
def set_previous_page_url #