README.md in simple_auth-3.1.3 vs README.md in simple_auth-3.1.4

- old
+ new

@@ -1,12 +1,11 @@ # Simple Auth -[![Travis-CI](https://travis-ci.org/fnando/simple_auth.svg)](https://travis-ci.org/fnando/simple_auth) -[![Code Climate](https://codeclimate.com/github/fnando/simple_auth/badges/gpa.svg)](https://codeclimate.com/github/fnando/simple_auth) -[![Test Coverage](https://codeclimate.com/github/fnando/simple_auth/badges/coverage.svg)](https://codeclimate.com/github/fnando/simple_auth/coverage) +[![Tests](https://github.com/fnando/simple_auth/workflows/ruby-tests/badge.svg)](https://github.com/fnando/simple_auth) [![Gem](https://img.shields.io/gem/v/simple_auth.svg)](https://rubygems.org/gems/simple_auth) [![Gem](https://img.shields.io/gem/dt/simple_auth.svg)](https://rubygems.org/gems/simple_auth) +[![MIT License](https://img.shields.io/:License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license) SimpleAuth is an authentication library to be used when everything else is just too complicated. This library only handles session. You have to implement the authentication @@ -134,15 +133,31 @@ #{scope}_logged_in? # e.g. user_logged_in? (available in controller & views) current_#{scope} # e.g. current_user (available in controller & views) #{scope}_session # e.g. user_session (available in controller & views) ``` +#### From your routes file + +You can also restrict routes directly from your routes: + +```ruby +Rails.application.routes.draw do + authenticate :admin, ->(user) { user.admin? } do + mount Sidekiq::Web, at: "sidekiq" + end +end +``` + +In this case, `:admin` is the scope and the lambda will only be called whenever +there's a valid record associated with that record. + ### Translations These are the translations you'll need: ```yaml +--- en: simple_auth: user: need_to_be_logged_in: "You need to be logged in" not_authorized: "You don't have permission to access this page" @@ -152,10 +167,11 @@ To display the error message, use something like `<%= flash[:alert] %>`. If you want to use a custom key, say `:error`, use the configuration file `config/initializers/simple_auth.rb` to define the new key: +```ruby # config/initializers/simple_auth.rb SimpleAuth.setup do |config| # ... config.flash_message_key = :error @@ -164,29 +180,27 @@ end ``` ## Maintainer -* Nando Vieira (<http://nandovieira.com>) +- [Nando Vieira](https://github.com/fnando) -## License: +## Contributors -(The MIT License) +- https://github.com/fnando/simple_auth/contributors -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +## Contributing -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +For more details about how to contribute, please read +https://github.com/fnando/simple_auth/blob/main/CONTRIBUTING.md. -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +## License + +The gem is available as open source under the terms of the +[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be +found at https://github.com/fnando/simple_auth/blob/main/LICENSE.md. + +## Code of Conduct + +Everyone interacting in the simple_auth project's codebases, issue trackers, +chat rooms and mailing lists is expected to follow the +[code of conduct](https://github.com/fnando/simple_auth/blob/main/CODE_OF_CONDUCT.md).