Class: Kadmin::Auth::UserStore

Inherits:
Object
  • Object
show all
Defined in:
lib/kadmin/auth/user_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ UserStore

Returns a new instance of UserStore.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/kadmin/auth/user_store.rb', line 4

def initialize(path = nil)
  @store = {}

  path ||= Rails.root.join('config', 'admin_users.yml')
  if File.exist?(path) && File.readable?(path)
    definitions = YAML.load_file(path.to_s)
    create_organizations(definitions['organizations'])
    load_users(definitions['users'])
  else
    Rails.logger.warn("Can't read admin users auth file at #{path}. Auth might not work")
  end
end

Instance Method Details

#exists?(email) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/kadmin/auth/user_store.rb', line 25

def exists?(email)
  @store.key?(email.to_s.downcase)
end

#get(email) ⇒ Object



17
18
19
# File 'lib/kadmin/auth/user_store.rb', line 17

def get(email)
  return @store[email.to_s.downcase]
end

#set(email, user) ⇒ Object



21
22
23
# File 'lib/kadmin/auth/user_store.rb', line 21

def set(email, user)
  @store[email.to_s.downcase] = user
end