Class: RegistrationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RegistrationsController
- Defined in:
- app/controllers/registrations_controller.rb
Overview
Handles new user signup; since new users get created during the invitaitons process, this controller merely serves up a 'new user' form, which updates the invited user's account with new password and potentially a different email address
Instance Method Summary collapse
-
#new ⇒ Object
GET /users/sign_up?token=abc123 Render invitation acceptance form.
-
#update ⇒ Object
PATCH /users Update the invited user's account with password and email address.
Instance Method Details
#new ⇒ Object
GET /users/sign_up?token=abc123 Render invitation acceptance form
11 12 13 14 15 16 |
# File 'app/controllers/registrations_controller.rb', line 11 def new token = params.require(:token) return unless setup_invitation(token) flash.now[:notice] = "Welcome to Coyote! After completing this form, you will become a member of the #{invitation.organization_title} organization." end |
#update ⇒ Object
PATCH /users Update the invited user's account with password and email address
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/registrations_controller.rb', line 21 def update token = user_attributes.delete(:token) return unless setup_invitation(token) user = invitation.recipient_user if user.update_attributes(user_attributes.except(:token)) logger.info "Successfully completed registration of #{user} for #{invitation}" invitation.redeem! sign_in(user) # Devise helper so user doesn't have to sign-in again; now the invited user is current_user redirect_to invitation.organization, notice: "Welcome to Coyote! You are now a member of the #{invitation.organization_title} organization." else logger.warn "Unable to complete registration for #{user} due to '#{user.error_sentence}'" render :new end end |