class Oxen::InvitationsController < Devise::InvitationsController # # POST /resource/invitation def create self.resource = invite_resource resource_invited = self.resource.errors.empty? yield resource if block_given? if resource_invited # if is_flashing_format? && self.resource.invitation_sent_at # set_flash_message :notice, :send_instructions, :email => self.resource.email # end flash[:info] = t('.invited') render layout: false, status: 200, locals: { result: true } else flash[:error] = t('.not_invited', error: resource.errors.collect{|v,k| k }.join(', ')) render layout: false, status: 401, locals: { result: false, resource: self.resource } # # respond_with resource, :location => after_invite_path_for(current_inviter) # else # respond_with_navigational(resource) { render :new } end end # def update # if this # redirect_to root_path # else # super # end # end private # this is called when creating invitation # should return an instance of resource class def invite_resource ## skip sending emails on invite resource_class.invite!(resource_params, current_user) # resource_class.invite!(resource_params, current_user) do |u| # # u.skip_invitation = true # end end def resource_params params[:user][:role] ||= "user" {email: params[:user][:email], name: params[:user][:name], account_id: params[:user][:account_id], role: params[:user][:role] } # {email: params[:user][:email], name: params[:user][:name], account_id: params[:user][:account_id] } # params.permit(user: [:name, :email,:invitation_token, :your_params_here])[:user] end # this is called when accepting invitation # should return an instance of resource class def accept_resource resource = resource_class.accept_invitation!(update_resource_params) ## Report accepting invitation to analytics # Analytics.report('invite.accept', resource.id) resource end # def after_invite_path_for(usr) # end end