diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/controllers/invites_controller.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/controllers/invites_controller.rb')
-rw-r--r-- | app/controllers/invites_controller.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 5bd9ac7f275..29cafbbbdb6 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -4,6 +4,7 @@ class InvitesController < ApplicationController include Gitlab::Utils::StrongMemoize before_action :member + before_action :invite_details skip_before_action :authenticate_user!, only: :decline helper_method :member?, :current_user_matches_invite? @@ -16,9 +17,8 @@ class InvitesController < ApplicationController def accept if member.accept_invite!(current_user) - label, path = source_info(member.source) - - redirect_to path, notice: _("You have been granted %{member_human_access} access to %{label}.") % { member_human_access: member.human_access, label: label } + redirect_to invite_details[:path], notice: _("You have been granted %{member_human_access} access to %{title} %{name}.") % + { member_human_access: member.human_access, title: invite_details[:title], name: invite_details[:name] } else redirect_back_or_default(options: { alert: _("The invitation could not be accepted.") }) end @@ -26,8 +26,6 @@ class InvitesController < ApplicationController def decline if member.decline_invite! - label, _ = source_info(member.source) - path = if current_user dashboard_projects_path @@ -35,7 +33,8 @@ class InvitesController < ApplicationController new_user_session_path end - redirect_to path, notice: _("You have declined the invitation to join %{label}.") % { label: label } + redirect_to path, notice: _("You have declined the invitation to join %{title} %{name}.") % + { title: invite_details[:title], name: invite_details[:name] } else redirect_back_or_default(options: { alert: _("The invitation could not be declined.") }) end @@ -76,24 +75,25 @@ class InvitesController < ApplicationController notice = notice.join(' ') + "." store_location_for :user, request.fullpath - redirect_to new_user_session_path, notice: notice + redirect_to new_user_session_path(invite_email: member.invite_email), notice: notice end - def source_info(source) - case source - when Project - project = member.source - label = "project #{project.full_name}" - path = project_path(project) - when Group - group = member.source - label = "group #{group.name}" - path = group_path(group) - else - label = "who knows what" - path = dashboard_projects_path - end - - [label, path] + def invite_details + @invite_details ||= case @member.source + when Project + { + name: @member.source.full_name, + url: project_url(@member.source), + title: _("project"), + path: project_path(@member.source) + } + when Group + { + name: @member.source.name, + url: group_url(@member.source), + title: _("group"), + path: group_path(@member.source) + } + end end end |