summaryrefslogtreecommitdiff
path: root/app/controllers/profiles/groups_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/profiles/groups_controller.rb')
-rw-r--r--app/controllers/profiles/groups_controller.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/controllers/profiles/groups_controller.rb b/app/controllers/profiles/groups_controller.rb
index bdd991bec06..9a4d088651e 100644
--- a/app/controllers/profiles/groups_controller.rb
+++ b/app/controllers/profiles/groups_controller.rb
@@ -7,12 +7,11 @@ class Profiles::GroupsController < ApplicationController
def leave
@users_group = group.users_groups.where(user_id: current_user.id).first
-
- if group.last_owner?(current_user)
- redirect_to(profile_groups_path, alert: "You can't leave group. You must add at least one more owner to it.")
- else
+ if can?(current_user, :destroy, @users_group)
@users_group.destroy
redirect_to(profile_groups_path, info: "You left #{group.name} group.")
+ else
+ return render_403
end
end