[bbb-greenlight: 14/39] Fixed 500 caused by editting a user when not allowed to (#2108)




commit 360783606e626712bd03898f0fee796c4933eea2
Author: Ahmad Farhat <ahmad af farhat gmail com>
Date:   Mon Sep 21 13:20:15 2020 -0400

    Fixed 500 caused by editting a user when not allowed to (#2108)

 app/controllers/users_controller.rb       | 6 +++---
 spec/controllers/users_controller_spec.rb | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index a061f24..3b26e52 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -223,8 +223,8 @@ class UsersController < ApplicationController
 
   # Checks that the user is allowed to edit this user
   def check_admin_of
-    redirect_to current_user.main_room if current_user &&
-                                          @user != current_user &&
-                                          !current_user.admin_of?(@user, "can_manage_users")
+    redirect_to root_path if current_user &&
+                             @user != current_user &&
+                             !current_user.admin_of?(@user, "can_manage_users")
   end
 end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 2a4624d..c86e306 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -65,7 +65,7 @@ describe UsersController, type: :controller do
 
       get :edit, params: { user_uid: user2.uid }
 
-      expect(response).to redirect_to(user.main_room)
+      expect(response).to redirect_to(root_path)
     end
 
     it "allows admins to edit other users" do


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]