Module: YiffSpace::Auth

Defined in:
lib/yiffspace/auth.rb,
lib/yiffspace/auth/client.rb,
lib/yiffspace/auth/engine.rb,
lib/yiffspace/auth/helper.rb,
lib/yiffspace/auth/auth_info.rb,
lib/yiffspace/auth/user_info.rb,
lib/yiffspace/auth/permissions.rb,
lib/yiffspace/auth/discord_info.rb,
lib/yiffspace/auth/set_client_name.rb,
lib/yiffspace/auth/auth_info/anonymous.rb,
lib/yiffspace/auth/user_info/anonymous.rb

Defined Under Namespace

Modules: Helper Classes: AuthInfo, Client, DiscordInfo, Engine, Permissions, SetClientName, UserInfo

Constant Summary collapse

CLIENT_NAME_ENV =
"yiffspace.auth.client_name"
DEFAULT_CLIENT_NAME =
:default

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



20
21
22
# File 'lib/yiffspace/auth.rb', line 20

def [](name)
  @clients[name.to_sym] || raise(KeyError, "unknown auth client: #{name.inspect}")
end

.defaultObject



24
25
26
# File 'lib/yiffspace/auth.rb', line 24

def default
  @clients[DEFAULT_CLIENT_NAME] || raise("no default client configured")
end

.disable_debug_action!Object



40
41
42
# File 'lib/yiffspace/auth.rb', line 40

def disable_debug_action!
  @enable_debug_action = false
end

.enable_debug_action!Object



36
37
38
# File 'lib/yiffspace/auth.rb', line 36

def enable_debug_action!
  @enable_debug_action = true
end

.enable_debug_action?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/yiffspace/auth.rb', line 32

def enable_debug_action?
  @enable_debug_action
end

.get_by_id(id) ⇒ Object



28
29
30
# File 'lib/yiffspace/auth.rb', line 28

def get_by_id(id)
  @clients.values.find { |c| c.client_id == id } || raise(ArgumentError, "unable to find client with id: #{id}")
end

.register(name, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/yiffspace/auth.rb', line 13

def register(name, &block)
  client = Client.new(name)
  block&.call(client)
  @clients[name.to_sym] = client
  client
end