Skip to content

Commit 1a2f679

Browse files
committed
Merge remote-tracking branch 'goto/release-1.2.0' into release-docker
2 parents 4aa6f92 + 00828a4 commit 1a2f679

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/controllers/api/v1/groups_controller.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ def remove_user
5959
end
6060

6161
def list_admins
62-
group = Group.find(params[:id])
62+
group = Group.find_by_id(params[:id])
63+
return head :not_found unless group.present?
64+
6365
users = group.group_admins.joins(:user).
6466
select('users.id, users.email, users.name, users.active, group_admins.created_at as join_date').
6567
where('users.active = ?', true)
6668
render json: users, status: :ok
6769
end
6870

6971
def associated_vpns
70-
group = Group.find(params[:id])
72+
group = Group.find_by_id(params[:id])
73+
return head :not_found unless group.present?
74+
7175
vpns = group.vpns
7276
render json: vpns, status: :ok
7377
end

app/controllers/api/v1/vpns_controller.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ class ::Api::V1::VpnsController < ::Api::V1::BaseController
33

44
def index
55
vpns = Vpn.order(:id).page(params[:page]).per(params[:per_page])
6+
vpns = vpns.where("name LIKE ?", "%#{params[:q]}%") if params[:q].present?
67
render json: vpns, status: :ok
78
end
89

910
def associated_groups
10-
vpn = Vpn.find(params[:id])
11+
vpn = Vpn.find_by_id(params[:id])
12+
return head :not_found unless vpn.present?
13+
1114
groups = vpn.groups
15+
groups = groups.where("name LIKE ?", "%#{params[:q]}%") if params[:q].present?
1216
render json: groups, status: :ok
1317
end
1418

0 commit comments

Comments
 (0)