Sha256: 15d884ae99855121e7ba6a520f3780994ba1dbe1f16446567ce8831b331660bb

Contents?: true

Size: 687 Bytes

Versions: 3

Compression:

Stored size: 687 Bytes

Contents

module Composable
  module Pwdless
    module RouterHelpers
      def composable_pwdless_for(resource, controller: nil, as: nil)
        as         ||= resource.to_s
        controller ||= "/composable/pwdless/auth"

        constraints(->(req) { (req.env["composable_pwdless_resource"] = resource.to_s).present? }) do
          scope resource.to_s, as: as do
            get   "/sign_in",  to: "#{controller}#new", as: :sign_in
            post  "/sign_in",  to: "#{controller}#create"
            put   "/sign_in",  to: "#{controller}#update"
            match "/sign_out", to: "#{controller}#destroy", via: :delete, as: :sign_out
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
composable-pwdless-0.0.12 lib/composable/pwdless/router_helpers.rb
composable-pwdless-0.0.11 lib/composable/pwdless/router_helpers.rb
composable-pwdless-0.0.10 lib/composable/pwdless/router_helpers.rb