Sha256: 1e7bfb5bfd9116ee028e7a828cbd3dd9f05ed223230d0b72cb3265dc44ee49a6

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

Contents

require 'hanami/commands/generate/abstract'
require 'hanami/application_name'
require 'securerandom'

module Hanami
  # @api private
  module Commands
    # @api private
    class Generate
      # @api private
      class SecretToken

        # @api private
        def initialize(application_name)
          @application_name = application_name
        end

        # @api private
        def start
          if Hanami::Utils::Blank.blank?(@application_name)
            puts SecureRandom.hex(32)
          else
            puts "Set the following environment variable to provide the secret token:"
            puts %(#{ upcase_app_name }_SESSIONS_SECRET="#{ SecureRandom.hex(32) }")
          end
        end

        private
        # @api private
        def upcase_app_name
          @application_name.upcase
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-1.0.0 lib/hanami/commands/generate/secret_token.rb
hanami-1.0.0.rc1 lib/hanami/commands/generate/secret_token.rb
hanami-1.0.0.beta3 lib/hanami/commands/generate/secret_token.rb