diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index ab1574347f479ae1fbe0200e6d944586ae357d37..ab9939a112998e734cde06c457d0600bf3b1476b 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -4,9 +4,10 @@ class InvitationsController < Devise::InvitationsController + before_filter :check_token, :only => [:edit] + def create - puts params.inspect begin params[:user][:aspect_id] = params[:user].delete(:aspects) self.resource = current_user.invite_user(params[resource_name]) @@ -39,4 +40,13 @@ class InvitationsController < Devise::InvitationsController redirect_to new_user_registration_path end end + + protected + + def check_token + if User.find_by_invitation_token(params['invitation_token']).nil? + flash[:error] = "Invitation token not found" + redirect_to root_url + end + end end