Method: Scrivito::Configuration.editing_auth

Defined in:
app/cms/scrivito/configuration.rb

.editing_auth(&block) {|env| ... } ⇒ Object

Configures a callback to be invoked when the SDK determines whether the current visitor is permitted to edit content.

If the callback is missing in the development or test environment, then the SDK will assume that the current visitor is User.system_user, who can always create workspaces, can always read, write, publish, delete and invite to any workspace.

If the callback is missing in any other environment (for example in production or staging), then the SDK will assume that the current visitor is not permitted to edit content.

Examples:

Scrivito::Configuration.editing_auth do |env|
  if user_id = env['USER_ID']
    Scrivito::User.define(user_id)
  end
end

Parameters:

  • block (Proc)

    proc for detemining if the current visitor is permitted to edit content

Yield Parameters:

  • env (Hash)

    rack env

Yield Returns:

  • (Scrivito::User)

    if the current visitor is permitted to edit content

  • (false, nil)

    if the current visitor is not permitted to edit content



49
50
51
52
53
54
55
# File 'app/cms/scrivito/configuration.rb', line 49

def self.editing_auth(&block)
  if block.respond_to?(:arity) && block.arity == 1
    @editing_auth_callback = block
  else
    raise ArgumentError, 'editing_auth should have only one attribute!'
  end
end