class

PrivateApi

Inherits Shield::PasswordResetPipes < Shield::Api::PasswordResetPipes < Shield::EmailConfirmationPipes < Shield::Api::EmailConfirmationPipes < Shield::LoginPipes < Shield::Api::LoginPipes < Shield::PasswordResetHelpers < Shield::Api::PasswordResetHelpers < Shield::EmailConfirmationHelpers < Shield::Api::EmailConfirmationHelpers < Shield::LoginHelpers < Shield::Api::LoginHelpers < Shield::ActionPipes < Shield::ActionHelpers < Lucille::ActionHelpers < Lucky::Paginator::BackendHelpers < Shield::ApiAction < Lucky::Action < Lucky::VerifyAcceptsFormat < Lucky::Redirectable < Habitat::SettingsHelpers < Habitat::TempConfig < Lucky::RequestBodyLimit < Lucky::ActionPipes < Lucky::ParamHelpers < Lucky::Renderable < Lucky::Routable < Lucky::Exposable < Lucky::RequestTypeHelpers < Lucky::ActionDelegates < Reference < Object

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

Constants

ACCEPTED_FORMAT_SYMBOLS = [:json]
AFTER_PIPES = [set_previous_page_url] of Symbol

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

BEFORE_PIPES = [verify_accepted_format, disable_caching, require_logged_in, require_logged_out, pin_login_to_ip_address, enforce_login_idle_timeout, check_authorization] of Symbol

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

EXPOSURES = [] of Symbol

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

PARAM_DECLARATIONS = [] of Crystal::Macros::TypeDeclaration

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

ROUTE_SETTINGS = { prefix: "/api"}

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

SKIPPED_PIPES = [pin_login_to_ip_address] of Symbol

This action accepts only Login tokens for authentication purposes.

It is useful if building an API backend for a decoupled frontend, where the frontend sends the user's email and password to the CurrentLogin::Create endpoint, in exchange for a Login token.

The token is typically saved in a session store (eg: cookies) on the frontend, and sent along in the Authorization header whenever a request is made to this backend API on the logged-in user's behalf.

Class methods

_accepted_formats

Instance methods

authorize?(__arg0 : Shield::User) : Bool | Nil
Source
authorize?
bearer_logged_in?
Source
bearer_logged_out?
Source
check_authorization
current_bearer
Source
current_bearer?
current_bearer_login
Source
current_bearer_login?
Source
current_login
current_login?
current_user
current_user?
Source
current_user_or_bearer

DEPRECATED User #current_user instead

Source
current_user_or_bearer?

DEPRECATED User #current_user? instead

Source
disable_caching
do_check_authorization_failed
Source
do_enforce_login_idle_timeout_failed
Source
do_pin_email_confirmation_to_ip_address_failed
Source
do_pin_login_to_ip_address_failed
Source
do_pin_password_reset_to_ip_address_failed
Source
do_require_logged_in_failed
Source
do_require_logged_out_failed
Source
enforce_login_idle_timeout
Source
logged_in?
logged_out?
paginator_per_page

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
Source
pin_email_confirmation_to_ip_address
Source
pin_login_to_ip_address
Source
pin_password_reset_to_ip_address
Source
previous_page_url
previous_page_url?
redirect_back(*, fallback : Lucky::Action.class, status : HTTP::Status, allow_external = false)
redirect_back(*, fallback : Lucky::RouteHelper, status : HTTP::Status, allow_external = false)
redirect_back(*, fallback : String, status : Int32 = 302, allow_external : Bool = false)

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.

remote_ip
remote_ip?
require_logged_in
Source
require_logged_out
return_url
return_url?
set_no_referrer_policy
set_previous_page_url

Macros

authorize
authorize_user