Module: LinkedRails::Auth::Routes

Defined in:
lib/linked_rails/auth/routes.rb

Constant Summary collapse

DOORKEEPER_CONTROLLERS =
{
  access_tokens: :tokens,
  applications: :applications,
  authorizations: :authorizations,
  authorized_applications: :authorized_applications,
  token_info: :token_info
}.freeze
DEVISE_CONTROLLERS =
i[omniauth_callbacks].freeze
LINKED_RAILS_CONTROLLERS =
{
  access_tokens: 'linked_rails/auth/access_tokens',
  confirmations: 'linked_rails/auth/confirmations',
  otp_attempts: 'linked_rails/auth/otp_attempts',
  otp_secrets: 'linked_rails/auth/otp_secrets',
  passwords: 'linked_rails/auth/passwords',
  registrations: 'linked_rails/auth/registrations',
  sessions: 'linked_rails/auth/sessions',
  unlocks: 'linked_rails/auth/unlocks'
}.freeze

Instance Method Summary collapse

Instance Method Details

#use_linked_rails_auth(opts = {}) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/linked_rails/auth/routes.rb', line 25

def use_linked_rails_auth(opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  linked_rails_doorkeeper_routes(opts)
  linked_rails_device_routes(opts)

  scope 'u' do
    get 'sign_in', to: redirect('/u/session/new')
  end
  devise_scope :user do
    auth_resource(AccessToken, opts)
    auth_resource(Confirmation, opts)
    auth_resource(OtpAttempt, opts)
    auth_resource(OtpSecret, opts)
    linked_resource(
      OtpSecret,
      controller: opts[:otp_secrets] || LINKED_RAILS_CONTROLLERS[:otp_secrets],
      nested: false
    )
    auth_resource(Password, opts)
    auth_resource(Registration, opts)
    auth_resource(Session, opts)
    auth_resource(Unlock, opts)
  end
end