Class: MogueraAuthentication::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/moguera_authentication/install.rb

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails/moguera_authentication/install.rb', line 4

def create_initializer_file
  initializer 'moguera_authentication.rb' do
    "      Rails.application.config.middleware.use Rack::MogueraAuthentication do |key|\n        secret_key = Rails.application.config.moguera_authentication.user_class\n          .find_by(Rails.application.config.moguera_authentication.find_key => key)\n          .try(Rails.application.config.moguera_authentication.secret_access_key)\n\n        unless secret_key\n          raise Moguera::Authentication::UserNotFound, \"access_key: \" + key\n        end\n\n        secret_key\n      end\n    FILE\n  end\nend\n".strip_heredoc