Module: GrapeTokenAuth::MountHelpers::ClassMethods

Defined in:
lib/grape_token_auth/mount_helpers.rb

Instance Method Summary collapse

Instance Method Details

#mount_confirmation(opts = {}) ⇒ Object



17
18
19
# File 'lib/grape_token_auth/mount_helpers.rb', line 17

def mount_confirmation(opts = {})
  mount_api('ConfirmationAPI', set_mount_point(opts, '/confirmation'))
end

#mount_omniauth(opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/grape_token_auth/mount_helpers.rb', line 29

def mount_omniauth(opts = {})
  path = opts.fetch(:to, '/')

  if opts.key?(:for)
    api = create_api_subclass('OmniAuthAPI', opts[:for])
  else
    api = GrapeTokenAuth::OmniAuthAPI
  end

  mount api => path
end

#mount_omniauth_callbacks(opts = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/grape_token_auth/mount_helpers.rb', line 41

def mount_omniauth_callbacks(opts = {})
  fail 'Oauth callback API is not scope specific. Only mount it once and do not pass a "for" option' if opts[:for]
  fail 'Oauth callback API path is specificed in the configuration. Do not pass a "to" option' if opts[:to]
  prefix = GrapeTokenAuth.set_omniauth_path_prefix!
  mount GrapeTokenAuth::OmniAuthCallBackRouterAPI => prefix
end

#mount_password_reset(opts = {}) ⇒ Object



25
26
27
# File 'lib/grape_token_auth/mount_helpers.rb', line 25

def mount_password_reset(opts = {})
  mount_api('PasswordAPI', set_mount_point(opts, '/password'))
end

#mount_registration(opts = {}) ⇒ Object



9
10
11
# File 'lib/grape_token_auth/mount_helpers.rb', line 9

def mount_registration(opts = {})
  mount_api('RegistrationAPI', opts)
end

#mount_sessions(opts = {}) ⇒ Object



13
14
15
# File 'lib/grape_token_auth/mount_helpers.rb', line 13

def mount_sessions(opts = {})
  mount_api('SessionsAPI', opts)
end

#mount_token_validation(opts = {}) ⇒ Object



21
22
23
# File 'lib/grape_token_auth/mount_helpers.rb', line 21

def mount_token_validation(opts = {})
  mount_api('TokenValidationAPI', opts)
end