class ActionDispatch::Routing::Mapper

Public Instance Methods

authenticatable(resource, options = {}) click to toggle source
# File lib/authenticatable/rails/routes.rb, line 6
def authenticatable(resource, options = {})
  # Placeholder method for authenticatable generator.
  scope = Authenticatable.add_scope(resource, options)
  authenticatable_scope scope do
    authenticatable_sessions(scope)
    authenticatable_registrations(scope)
    authenticatable_passwords(scope)
  end
end

Protected Instance Methods

authenticatable_passwords(scope) click to toggle source
# File lib/authenticatable/rails/routes.rb, line 49
def authenticatable_passwords(scope)
  return if scope.skip.include? :passwords

  resource :password, only: [], path: "", controller: scope.controllers[:passwords] do
    get :new, path: scope.path_names[:forgot_password], as: :new
    post :create, path: scope.path_names[:forgot_password]
    get :edit, path: scope.path_names[:reset_password], as: :edit
    patch :update, path: scope.path_names[:reset_password], as: :update
  end
end
authenticatable_registrations(scope) click to toggle source
# File lib/authenticatable/rails/routes.rb, line 40
def authenticatable_registrations(scope)
  return if scope.skip.include? :registrations

  resource :registration, only: [], path: "", controller: scope.controllers[:registrations] do
    get :new, path: scope.path_names[:sign_up], as: :new
    post :create, path: scope.path_names[:sign_up]
  end
end
authenticatable_scope(scope, &block) click to toggle source
# File lib/authenticatable/rails/routes.rb, line 18
def authenticatable_scope(scope, &block)
  constraint = lambda do |request|
    request.env["authenticatable.scope"] = scope
    true
  end

  constraints(constraint) do
    scope scope.path, as: scope.singular_name, &block
  end
end
authenticatable_sessions(scope) click to toggle source
# File lib/authenticatable/rails/routes.rb, line 29
def authenticatable_sessions(scope)
  return if scope.skip.include? :sessions

  resource :session, only: [], path: "", controller: scope.controllers[:sessions] do
    get :new, path: scope.path_names[:sign_in], as: :new
    post :create, path: scope.path_names[:sign_in]
    match :destroy, path: scope.path_names[:sign_out], as: :destroy,
                    via: Authenticatable.config.allowed_sign_out_methods
  end
end