Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-10 16:22:31 +0300
committerDouwe Maan <douwe@gitlab.com>2015-04-14 13:07:33 +0300
commit39f389ae0fff5706b73b03c8fb5fc4e3dd7da638 (patch)
tree405b1daea83883b1fc416ca21749da4282576117 /app/controllers
parent90dafe31c4b1bb54bcd0476a873c4f5cdb62e981 (diff)
Add invites controller.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/confirmations_controller.rb4
-rw-r--r--app/controllers/invites_controller.rb57
2 files changed, 59 insertions, 2 deletions
diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb
index bc98eab133c..af1faca93f6 100644
--- a/app/controllers/confirmations_controller.rb
+++ b/app/controllers/confirmations_controller.rb
@@ -4,11 +4,11 @@ class ConfirmationsController < Devise::ConfirmationsController
def after_confirmation_path_for(resource_name, resource)
if signed_in?(resource_name)
- signed_in_root_path(resource)
+ after_sign_in_path_for(resource)
else
sign_in(resource)
if signed_in?(resource_name)
- signed_in_root_path(resource)
+ after_sign_in_path_for(resource)
else
new_session_path(resource_name)
end
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
new file mode 100644
index 00000000000..8b1f6eeba1b
--- /dev/null
+++ b/app/controllers/invites_controller.rb
@@ -0,0 +1,57 @@
+class InvitesController < ApplicationController
+ before_filter :member
+
+ respond_to :html
+
+ layout 'navless'
+
+ def show
+
+ end
+
+ def accept
+ if member.accept_invite!(current_user)
+ case member.source
+ when Project
+ project = member.source
+ source = "project #{project.name_with_namespace}"
+ path = namespace_project_path(project.namespace, project)
+ when Group
+ group = member.source
+ source = "group #{group.name}"
+ path = group_path(group)
+ else
+ source = "who knows what"
+ path = dashboard_path
+ end
+
+ redirect_to path, notice: "You have been granted #{member.human_access} access to #{source}."
+ else
+ redirect_to :back, alert: "The invite could not be accepted."
+ end
+ end
+
+ private
+
+ def member
+ return @member if defined?(@member)
+
+ @token = params[:id]
+ if member = Member.find_by_invite_token(@token)
+ @member = member
+ else
+ render_404
+ end
+ end
+
+ def authenticate_user!
+ return if current_user
+
+ notice = "To accept this invitation, sign in"
+ notice << " or create an account" if current_application_settings.signup_enabled?
+ notice << "."
+
+ store_location_for :user, request.fullpath
+ redirect_to new_user_session_path, notice: notice
+ end
+end