Sha256: a9d976cd124a939d8a62534b474a733aecba584a6359ae9e5d3a577483c742ce

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

class RegistrationsController < ApplicationController
  skip_before_action :authenticate, only: %i[ new create ]

  def new
    @<%= singular_table_name %> = <%= class_name %>.new
  end

  def create
    @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)

    if @<%= singular_table_name %>.save
      session = @<%= singular_table_name %>.sessions.create!(session_params)
      cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }

      redirect_to root_path, notice: "Welcome! You have signed up successfully"
    else
      render :new, status: :unprocessable_entity
    end
  end

  def destroy
    Current.<%= singular_table_name %>.destroy; redirect_to(sign_in_path, notice: "Your account is closed")
  end

  private
    def <%= "#{singular_table_name}_params" %>
      params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation)
    end

    def session_params
      { user_agent: request.user_agent, ip_address: request.remote_ip, sudo_at: Time.current }
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
authentication-zero-2.8.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.7.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.6.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.5.1 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.5.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.4.0 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
authentication-zero-2.3.6 lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt