|
|
@ -2,6 +2,7 @@ class UsersController < ApplicationController |
|
|
|
include Pagy::Backend |
|
|
|
include Pagy::Backend |
|
|
|
include Devise::Controllers::SignInOut |
|
|
|
include Devise::Controllers::SignInOut |
|
|
|
include Helpers::Email |
|
|
|
include Helpers::Email |
|
|
|
|
|
|
|
include Modules::UsersFilter |
|
|
|
before_action :authenticate_user! |
|
|
|
before_action :authenticate_user! |
|
|
|
before_action :find_resource, except: %i[new create] |
|
|
|
before_action :find_resource, except: %i[new create] |
|
|
|
before_action :authenticate_scope!, except: %i[new] |
|
|
|
before_action :authenticate_scope!, except: %i[new] |
|
|
@ -9,7 +10,7 @@ class UsersController < ApplicationController |
|
|
|
def index |
|
|
|
def index |
|
|
|
redirect_to users_organisation_path(current_user.organisation) unless current_user.support? |
|
|
|
redirect_to users_organisation_path(current_user.organisation) unless current_user.support? |
|
|
|
|
|
|
|
|
|
|
|
@pagy, @users = pagy(filtered_users) |
|
|
|
@pagy, @users = pagy(filtered_users(User.all)) |
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
respond_to do |format| |
|
|
|
format.html |
|
|
|
format.html |
|
|
@ -77,14 +78,6 @@ class UsersController < ApplicationController |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def filtered_users |
|
|
|
|
|
|
|
if (search_param = params["user-search-field"]) |
|
|
|
|
|
|
|
User.search_by(search_param) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
User.all |
|
|
|
|
|
|
|
end.filter_by_active.includes(:organisation) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_error_messages |
|
|
|
def format_error_messages |
|
|
|
errors = @user.errors.to_hash |
|
|
|
errors = @user.errors.to_hash |
|
|
|
@user.errors.clear |
|
|
|
@user.errors.clear |
|
|
|