Class: OauthIm::ProxyUser

Inherits:
IdpClient show all
Includes:
HasRegistrationData
Defined in:
app/services/oauth_im/proxy_user.rb

Instance Attribute Summary collapse

Attributes inherited from IdpClient

#api_key, #idp_url

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasRegistrationData

#active?, #application_id, #email, #first_name, #full_name, #last_name, #login_id, #registration, #registration_data, #registrations, #sponsor?, #user_is_sponsor?

Methods inherited from IdpClient

default_api_key, default_idp_url

Constructor Details

#initialize(opts) ⇒ ProxyUser

Returns a new instance of ProxyUser.



20
21
22
23
24
# File 'app/services/oauth_im/proxy_user.rb', line 20

def initialize(opts)
  @attrs = (opts || {}).to_h.with_indifferent_access
  super api_key: @attrs[:api_key],
        idp_url: @attrs[:idp_url]
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



18
19
20
# File 'app/services/oauth_im/proxy_user.rb', line 18

def attrs
  @attrs
end

Class Method Details

.for(user_id:) ⇒ Object



14
15
16
# File 'app/services/oauth_im/proxy_user.rb', line 14

def self.for(user_id:)
  AdminClient.new.proxy_user_for user_id: user_id
end

Instance Method Details

#deactivateObject



51
52
53
54
# File 'app/services/oauth_im/proxy_user.rb', line 51

def deactivate
  client.deactivate_user user_id
  reset_attrs
end

#grant_sponsorshipObject



26
27
28
# File 'app/services/oauth_im/proxy_user.rb', line 26

def grant_sponsorship
  update_registration { |data| data[:sponsor] = 'true' }
end

#reactivateObject



56
57
58
59
# File 'app/services/oauth_im/proxy_user.rb', line 56

def reactivate
  client.reactivate_user user_id
  reset_attrs
end

#revoke_sponsorshipObject



30
31
32
# File 'app/services/oauth_im/proxy_user.rb', line 30

def revoke_sponsorship
  update_registration { |data| data[:sponsor] = 'false' }
end

#send_reset_password_emailObject



42
43
44
45
# File 'app/services/oauth_im/proxy_user.rb', line 42

def send_reset_password_email
  client.forgot_password loginId: 
  reset_attrs
end

#set_password(password, change_required: true) ⇒ Object



47
48
49
# File 'app/services/oauth_im/proxy_user.rb', line 47

def set_password(password, change_required: true)
  update_user(password: password, passwordChangeRequired: change_required)
end

#to_hObject



34
35
36
# File 'app/services/oauth_im/proxy_user.rb', line 34

def to_h
  os_to_h attrs
end

#user_idObject



38
39
40
# File 'app/services/oauth_im/proxy_user.rb', line 38

def user_id
  attrs[:id]
end