Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wbotelhos committed Sep 7, 2021
1 parent b6d7dd5 commit 84ec131
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.3.0

## Features

- Added options `field` to customize how the authorizy field is fetched;

# v0.2.2

## Fixes
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
authorizy (0.2.2)
authorizy (0.3.0)

GEM
remote: https://rubygems.org/
Expand Down
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/authorizy/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Authorizy
VERSION = '0.2.2'
VERSION = '0.3.0'
end

0 comments on commit 84ec131

Please sign in to comment.