diff options
Diffstat (limited to 'app/helpers/users_helper.rb')
-rw-r--r-- | app/helpers/users_helper.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 29998a996e2..ac279904fd2 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -104,6 +104,24 @@ module UsersHelper Gitlab.config.gitlab.impersonation_enabled end + def can_impersonate_user(user, impersonation_in_progress) + can?(user, :log_in) && !user.password_expired? && !impersonation_in_progress + end + + def impersonation_error_text(user, impersonation_in_progress) + if impersonation_in_progress + _("You are already impersonating another user") + elsif user.blocked? + _("You cannot impersonate a blocked user") + elsif user.password_expired? + _("You cannot impersonate a user with an expired password") + elsif user.internal? + _("You cannot impersonate an internal user") + else + _("You cannot impersonate a user who cannot log in") + end + end + def user_badges_in_admin_section(user) [].tap do |badges| badges << blocked_user_badge(user) if user.blocked? @@ -208,6 +226,24 @@ module UsersHelper end end + def user_profile_actions_data(user) + basic_actions_data = { + user_id: user.id + } + + if can?(current_user, :read_user_profile, user) + basic_actions_data[:rss_subscription_path] = user_path(user, rss_url_options) + end + + return basic_actions_data if !current_user || current_user == user + + basic_actions_data.merge( + report_abuse_path: add_category_abuse_reports_path, + reported_user_id: user.id, + reported_from_url: user_url(user) + ) + end + private def admin_users_paths |