class Rails::Generators::AuthenticationGenerator
:nodoc:
def add_migrations
def add_migrations generate "migration CreateUsers email_address:string!:uniq password_digest:string! --force" generate "migration CreateSessions user:references ip_address:string user_agent:string --force" end
def configure_application_controller
def configure_application_controller inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n" end
def configure_authentication_routes
def configure_authentication_routes route "resources :passwords, param: :token" route "resource :session" end
def create_authentication_files
def create_authentication_files template "app/models/session.rb" template "app/models/user.rb" template "app/models/current.rb" template "app/controllers/sessions_controller.rb" template "app/controllers/concerns/authentication.rb" template "app/controllers/passwords_controller.rb" template "app/channels/application_cable/connection.rb" if defined?(ActionCable::Engine) template "app/mailers/passwords_mailer.rb" template "app/views/passwords_mailer/reset.html.erb" template "app/views/passwords_mailer/reset.text.erb" template "test/mailers/previews/passwords_mailer_preview.rb" end
def enable_bcrypt
def enable_bcrypt if File.read("Gemfile").include?('gem "bcrypt"') uncomment_lines "Gemfile", /gem "bcrypt"/ Bundler.with_original_env { execute_command :bundle, "install --quiet" } else Bundler.with_original_env { execute_command :bundle, "add bcrypt", capture: true } end end