Sha256: 2687c8c7fe1726bd30bae6d6e2eb5456e36e628ec2e103fb5b3606e8eb6840fa

Contents?: true

Size: 729 Bytes

Versions: 5

Compression:

Stored size: 729 Bytes

Contents

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

module Hanami
  module Commands
    class Generate
      class SecretToken

        def initialize(application_name)
          @application_name = application_name
        end

        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
        def upcase_app_name
          @application_name.upcase
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-1.0.0.beta2 lib/hanami/commands/generate/secret_token.rb
hanami-1.0.0.beta1 lib/hanami/commands/generate/secret_token.rb
hanami-0.9.2 lib/hanami/commands/generate/secret_token.rb
hanami-0.9.1 lib/hanami/commands/generate/secret_token.rb
hanami-0.9.0 lib/hanami/commands/generate/secret_token.rb