Class: Rad::Web::Processors::PrepareAutenticityToken

Inherits:
Conveyors::Processor show all
Defined in:
lib/rad/web/_protect_from_forgery.rb

Overview

Processor

Instance Attribute Summary

Attributes inherited from Conveyors::Processor

#next_processor

Instance Method Summary collapse

Methods inherited from Conveyors::Processor

#initialize, inspect

Constructor Details

This class inherits a constructor from Rad::Conveyors::Processor

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rad/web/_protect_from_forgery.rb', line 5

def call
  if rad.http.session
    request = workspace.request.must_be.defined
    params = workspace.params.must_be.defined

    token = request.session['authenticity_token']

    if token.blank? and request.get?
      token = generate_authenticity_token
      request.session['authenticity_token'] = token
    end
  end

  next_processor.call
end