Class: RippleKeycloak::User
Class Method Summary
collapse
Methods inherited from BaseModel
all, delete, find, find_by, object_type, search
Class Method Details
.add_role(user_id, role_name) ⇒ Object
29
30
31
32
|
# File 'lib/ripple_keycloak/user.rb', line 29
def add_role(user_id, role_name)
role = RippleKeycloak::Role.find_by(field: 'name', value: role_name)
client.post("users/#{user_id}/role-mappings/realm", [role])
end
|
.add_to_group(user_id, group_id) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/ripple_keycloak/user.rb', line 15
def add_to_group(user_id, group_id)
client.put(
"users/#{user_id}/groups/#{group_id}",
{
groupId: group_id,
userId: user_id
}
)
end
|
.create(payload) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/ripple_keycloak/user.rb', line 8
def create(payload)
response = client.post('users', payload)
user_id = response.['location'].split('/').last
user_id
end
|
.remove_from_group(user_id, group_id) ⇒ Object
25
26
27
|
# File 'lib/ripple_keycloak/user.rb', line 25
def remove_from_group(user_id, group_id)
client.delete("users/#{user_id}/groups/#{group_id}")
end
|
.remove_role(user_id, role_name) ⇒ Object
34
35
36
37
|
# File 'lib/ripple_keycloak/user.rb', line 34
def remove_role(user_id, role_name)
role = RippleKeycloak::Role.find_by(field: 'name', value: role_name)
client.delete("users/#{user_id}/role-mappings/realm", [role])
end
|
.send_email(user_id, actions, lifespan: 86_400, client_id: false, redirect_uri: false) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/ripple_keycloak/user.rb', line 39
def send_email(user_id, actions, lifespan: 86_400, client_id: false, redirect_uri: false)
url = "users/#{user_id}/execute-actions-email?"
url += "?lifespan=#{lifespan}"
url += "&client_id=#{client_id}" if client_id
url += "&redirect_uri=#{redirect_uri}" if redirect_uri
client.put(url, actions)
end
|