Sha256: 76de75500fa507f154bbf17f7693c2d8c5d791c0630e99cc1410d090c0812d0e

Contents?: true

Size: 579 Bytes

Versions: 43

Compression:

Stored size: 579 Bytes

Contents

module Scrivito
  class SessionsController < WebserviceController
    def update
      @session = fetch_session(params.fetch(:id))
    end

    private

    def fetch_session(id)
      payload = {
        session: {
          role: 'editor',
          user_id: scrivito_user.id,
          permissions: permissions(scrivito_user),
        }
      }

      CmsRestApi.task_unaware_request(:put, "sessions/#{id}", payload)
    end

    def permissions(user)
      Hash[user.explicit_rules.map do |permission, verb, _, _|
        [verb, permission.to_s]
      end]
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
scrivito_sdk-1.7.0 app/controllers/scrivito/sessions_controller.rb
scrivito_sdk-1.7.0.rc2 app/controllers/scrivito/sessions_controller.rb
scrivito_sdk-1.7.0.rc1 app/controllers/scrivito/sessions_controller.rb