diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /app/controllers/users_controller.rb | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r-- | app/controllers/users_controller.rb | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9546f71cd37..4db5745c005 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -9,20 +9,21 @@ class UsersController < ApplicationController include Gitlab::NoteableMetadata requires_cross_project_access show: false, - groups: false, - projects: false, - contributed: false, - snippets: true, - calendar: false, - followers: false, - following: false, - calendar_activities: true + groups: false, + projects: false, + contributed: false, + snippets: true, + calendar: false, + followers: false, + following: false, + calendar_activities: true skip_before_action :authenticate_user! prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) } before_action :user, except: [:exists] - before_action :authorize_read_user_profile!, - only: [:calendar, :calendar_activities, :groups, :projects, :contributed, :starred, :snippets, :followers, :following] + before_action :authorize_read_user_profile!, only: [ + :calendar, :calendar_activities, :groups, :projects, :contributed, :starred, :snippets, :followers, :following + ] before_action only: [:exists] do check_rate_limit!(:username_exists, scope: request.ip) end @@ -71,7 +72,19 @@ class UsersController < ApplicationController format.json do load_events - pager_json("events/_events", @events.count, events: @events) + + if Feature.enabled?(:profile_tabs_vue, current_user) + @events = if user.include_private_contributions? + @events + else + @events.select { |event| event.visible_to_user?(current_user) } + end + + render json: ::Profile::EventSerializer.new(current_user: current_user, target_user: user) + .represent(@events) + else + pager_json("events/_events", @events.count, events: @events) + end end end end @@ -169,7 +182,7 @@ class UsersController < ApplicationController def exists if Gitlab::CurrentSettings.signup_enabled? || current_user - render json: { exists: !!Namespace.find_by_path_or_name(params[:username]) } + render json: { exists: !!Namespace.without_project_namespaces.find_by_path_or_name(params[:username]) } else render json: { error: _('You must be authenticated to access this path.') }, status: :unauthorized end @@ -178,7 +191,12 @@ class UsersController < ApplicationController def follow followee = current_user.follow(user) - flash[:alert] = followee.errors.full_messages.join(', ') if followee&.errors&.any? + if followee + flash[:alert] = followee.errors.full_messages.join(', ') if followee&.errors&.any? + else + flash[:alert] = s_('Action not allowed.') + end + redirect_path = referer_path(request) || @user redirect_to redirect_path |