From 84ec131db34bba1574d4a06aabcec59e9e885725 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Tue, 7 Sep 2021 11:01:47 -0300 Subject: [PATCH] v0.3.0 --- CHANGELOG.md | 6 +++++ Gemfile.lock | 2 +- README.md | 48 ++++++++++++++++++++++++---------------- lib/authorizy/version.rb | 2 +- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeeecb8..dbf11f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.3.0 + +## Features + +- Added options `field` to customize how the authorizy field is fetched; + # v0.2.2 ## Fixes diff --git a/Gemfile.lock b/Gemfile.lock index 8a2610c..878d027 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - authorizy (0.2.2) + authorizy (0.3.0) GEM remote: https://rubygems.org/ diff --git a/README.md b/README.md index 6468c59..9119238 100644 --- a/README.md +++ b/README.md @@ -84,25 +84,6 @@ Authorizy.configure do |config| end ``` -### Dependencies - -You can allow access to one or more controllers and actions based on your permissions. It'll consider not only the `action`, like [aliases](#aliases) but the controller either. - -```ruby -Authorizy.configure do |config| - config.dependencies = { - payments: { - index: [ - ['system/users', :index], - ['system/enrollments', :index], - ] - } - } -end -``` - -So now if a have the permission `payments#index` I'll receive more two permissions: `users#index` and `enrollments#index`. - ### Cop Sometimes we need to allow access in runtime because the permission will depend on the request data and/or some dynamic logic. For this you can create a *Cop* class, that inherits from `Authorizy::BaseCop`, to allow it based on logic. It works like a [Interceptor](https://en.wikipedia.org/wiki/Interceptor_pattern). @@ -161,6 +142,35 @@ Authorizy.configure do |config| end ``` +### Dependencies + +You can allow access to one or more controllers and actions based on your permissions. It'll consider not only the `action`, like [aliases](#aliases) but the controller either. + +```ruby +Authorizy.configure do |config| + config.dependencies = { + payments: { + index: [ + ['system/users', :index], + ['system/enrollments', :index], + ] + } + } +end +``` + +So now if a have the permission `payments#index` I'll receive more two permissions: `users#index` and `enrollments#index`. + +### Field + +By default the permissions are located inside the field called `authorizy` in the configured `current_user`. You can change how this field is fetched: + +```ruby +Authorizy.configure do |config| + @field = ->(current_user) { current_user.profile.authorizy } +end +``` + ### Redirect URL When authorization fails and the request is not a XHR request a redirect happens to `/` path. You can change it: diff --git a/lib/authorizy/version.rb b/lib/authorizy/version.rb index d96cae3..3564cba 100644 --- a/lib/authorizy/version.rb +++ b/lib/authorizy/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Authorizy - VERSION = '0.2.2' + VERSION = '0.3.0' end