Class: Kaui::User

Inherits:
ApplicationRecord show all
Defined in:
app/models/kaui/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Managed by Devise


8
9
10
# File 'app/models/kaui/user.rb', line 8

def password
  @password
end

Class Method Details

.find_permissions(kb_username, kb_password) ⇒ Object

Called by Devise to perform authentication Throws KillBillClient::API::Unauthorized on failure


12
13
14
15
# File 'app/models/kaui/user.rb', line 12

def self.find_permissions(kb_username, kb_password)
  do_find_permissions :username => kb_username,
                      :password => kb_password
end

Instance Method Details

#authenticated_with_killbill?Boolean

Verify the Kill Bill session hasn't timed-out

Returns:

  • (Boolean)

24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/kaui/user.rb', line 24

def authenticated_with_killbill?
  begin
    subject = KillBillClient::Model::Security.find_subject :session_id => kb_session_id
    result = subject.is_authenticated
    return result
  rescue Errno::ECONNREFUSED => e
    false
  rescue KillBillClient::API::Unauthorized => e
    false
  end
end

#permissionsObject

Called by CanCan to perform authorization Throws KillBillClient::API::Unauthorized on failure


19
20
21
# File 'app/models/kaui/user.rb', line 19

def permissions
  User.do_find_permissions :session_id => kb_session_id
end

#root?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'app/models/kaui/user.rb', line 36

def root?
  Kaui.root_username == kb_username
end