Sha256: c5fe03a92ebecb76b767f89bc808e7abaca832612305a648b5542173c25d2df2

Contents?: true

Size: 660 Bytes

Versions: 31

Compression:

Stored size: 660 Bytes

Contents

class InvitationsController < ApplicationController
  def new
    @user = User.new
  end

  def create
    @user = User.create_with(user_params).find_or_initialize_by(email: params[:email])

    if @user.save
      send_invitation_instructions
      redirect_to new_invitation_path, notice: "An invitation email has been sent to #{@user.email}"
    else
      render :new, status: :unprocessable_entity
    end
  end

  private
    def user_params
      params.permit(:email).merge(password: SecureRandom.base58, verified: true)
    end

    def send_invitation_instructions
      UserMailer.with(user: @user).invitation_instructions.deliver_later
    end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
authentication-zero-4.0.3 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-4.0.2 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-4.0.1 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-4.0.0 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-3.0.2 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-3.0.1 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-3.0.0 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-3.0.0.alpha1 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.36 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.35 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.34 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.33 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.32 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.31 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.30 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.29 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.28 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.27 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.26 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
authentication-zero-2.16.25 lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt