Class: Hanami::Commands::Generate::SecretToken

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/commands/generate/secret_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(application_name) ⇒ SecretToken

Returns a new instance of SecretToken


10
11
12
# File 'lib/hanami/commands/generate/secret_token.rb', line 10

def initialize(application_name)
  @application_name = application_name
end

Instance Method Details

#startObject


14
15
16
17
18
19
20
21
# File 'lib/hanami/commands/generate/secret_token.rb', line 14

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