Class: Scimaenaga::ScimUsersController
Constant Summary
Constants included
from Response
Response::CONTENT_TYPE
Instance Method Summary
collapse
Methods included from Response
#json_response, #json_scim_response
Instance Method Details
#create ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/scimaenaga/scim_users_controller.rb', line 35
def create
if Scimaenaga.config.scim_user_prevent_update_on_create
user = @company
.public_send(Scimaenaga.config.scim_users_scope)
.create!(permitted_user_params)
else
username_key = Scimaenaga.config.queryable_user_attributes[:userName]
find_by_username = {}
find_by_username[username_key] = permitted_user_params[username_key]
user = @company
.public_send(Scimaenaga.config.scim_users_scope)
.find_or_create_by(find_by_username)
user.update!(permitted_user_params)
end
json_scim_response(object: user, status: :created)
end
|
#index ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/scimaenaga/scim_users_controller.rb', line 6
def index
if params[:filter].present?
query = Scimaenaga::ScimQueryParser.new(
params[:filter], Scimaenaga.config.queryable_user_attributes
)
users = @company
.public_send(Scimaenaga.config.scim_users_scope)
.where(
"#{Scimaenaga.config.scim_users_model
.connection.quote_column_name(query.attribute)} #{query.operator} ?",
query.parameter
)
.order(Scimaenaga.config.scim_users_list_order)
else
users = @company
.public_send(Scimaenaga.config.scim_users_scope)
.order(Scimaenaga.config.scim_users_list_order)
end
counts = ScimCount.new(
start_index: params[:startIndex],
limit: params[:count],
total: users.count
)
json_scim_response(object: users, counts: counts)
end
|
#patch_update ⇒ Object
63
64
65
66
67
68
69
|
# File 'app/controllers/scimaenaga/scim_users_controller.rb', line 63
def patch_update
user = @company.public_send(Scimaenaga.config.scim_users_scope).find(params[:id])
patch = ScimPatch.new(params, :user)
patch.save(user)
json_scim_response(object: user)
end
|
#put_update ⇒ Object
57
58
59
60
61
|
# File 'app/controllers/scimaenaga/scim_users_controller.rb', line 57
def put_update
user = @company.public_send(Scimaenaga.config.scim_users_scope).find(params[:id])
user.update!(permitted_user_params)
json_scim_response(object: user)
end
|
#show ⇒ Object
52
53
54
55
|
# File 'app/controllers/scimaenaga/scim_users_controller.rb', line 52
def show
user = @company.public_send(Scimaenaga.config.scim_users_scope).find(params[:id])
json_scim_response(object: user)
end
|