diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1e2cf536..f3cb5248 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -194,6 +194,14 @@ class ApplicationController < ActionController::Base
end
helper_method :allowed_file_types
+ # Allows admins to edit a user's details
+ def can_edit_user?(user_to_edit, editting_user)
+ return user_to_edit.greenlight_account? if user_to_edit == editting_user
+
+ editting_user.admin_of?(user_to_edit, "can_manage_users")
+ end
+ helper_method :can_edit_user?
+
# Returns the page that the logo redirects to when clicked on
def home_page
return admins_path if current_user.has_role? :super_admin
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d1464e9d..70db2471 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -92,7 +92,7 @@ class UsersController < ApplicationController
redirect_path = current_user.admin_of?(@user, "can_manage_users") ? path : edit_user_path(@user)
- unless @user.greenlight_account?
+ unless can_edit_user?(@user, current_user)
params[:user][:name] = @user.name
params[:user][:email] = @user.email
end
diff --git a/app/views/users/components/_account.html.erb b/app/views/users/components/_account.html.erb
index 72268317..30a31bfa 100644
--- a/app/views/users/components/_account.html.erb
+++ b/app/views/users/components/_account.html.erb
@@ -13,6 +13,8 @@
# with BigBlueButton; if not, see