Yet Another Authentication Gem (YAAG) provides passwordless authentication for your rails app, all it takes is the user's e-mail address.
No password. No e-mail confirmation. No registration.
bundle add yaag
bundle install
rails g authentication:install
rails db:migrate
It's the same mechanics of password reset in traditional authentication: the user provides an e-amil address and receives a link with a token to sign in. At its core, it implements the same logic of the built-in rails authentication (in fact most of the gem's code came from the rails library).
Add this line to your application's Gemfile:
bundle add yaagAnd then execute:
bundleGenerate the authentication components (migrations, etc):
rails g authentication:installFollow the on-screen post-installation instructions.
By default, all controllers require signing in via the inclusion of include Authentication in the ApplicationController. If you have a route that doesn't require signing in, add allow_unauthenticated_access to it:
class GuestController < ApplicationController
allow_unauthenticated_access only: %i[ index ]
...
end
Get the current user with Current.user and the current session with Current.session
class MyController < ApplicationController
def something
user = Current.user
session = Current.session
...
end
end
To create a copy of the views for customization, run:
rails g authentication:copy:viewsgit tag $(bundle exec rake version | tr -d '"') && git push --tagsThe gem is available as open source under the terms of the MIT License.