Skip to content

Instantly share code, notes, and snippets.

@Gowiem
Created June 3, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gowiem/7a71537904eacd356037a3c1602538d7 to your computer and use it in GitHub Desktop.
Save Gowiem/7a71537904eacd356037a3c1602538d7 to your computer and use it in GitHub Desktop.
# backend/app/controllers/users_invitations_controller.rb
class UsersInvitationsController < Devise::InvitationsController
def edit
sign_out send("current_#{resource_name}") if send("#{resource_name}_signed_in?")
set_minimum_password_length
resource.invitation_token = params[:invitation_token]
redirect_to "http://localhost:8080/users/invitation/accept?invitation_token=#{params[:invitation_token]}"
end
def update
super do |resource|
if resource.errors.empty?
render json: { status: "Invitation Accepted!" }, status: 200 and return
else
render json: resource.errors, status: 401 and return
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment