Has Email Authentication
HasEmailAuthentication, for Rails/ActiveRecord 5.0+, is a micro library that compliments has_secure_password
by providing has_email_authentication
.
This library was developed for- and extracted from HireFire.
The documentation can be found on RubyDoc.
Compatibility
- Rails/ActiveRecord 5.0+
- Ruby (MRI) 2.5+
Installation
Add the gem to your Gemfile and run bundle
.
gem "has_email_authentication"
Example
This library requires you to have an email
column in the table associated
with the model you're using.
class User < ActiveRecord::Base
has_email_authentication
end
This does a few things:
- Adds presence, format and uniqueness validations on
email
- Downcases
email
before saving the record - Provides a
User.find_by_email(params[:email])
convenience method which downcases the provided email
Contributing
Contributions are welcome, but please conform to these requirements:
- Ruby (MRI) 2.5+
- ActiveRecord 5.0+
- 100% Spec Coverage
- Generated by when running the test suite
- 100% Passing Specs
- Run test suite with
$ rspec spec
- Run test suite with
- 4.0 Code Climate Score
- Run
$ rubycritic lib
to generate the score locally and receive tips - No code smells
- No duplication
- Run
To start contributing, fork the project, clone it, and install the development dependencies:
git clone git@github.com:USERNAME/has_email_authentication.git
cd has_email_authentication
bundle
Ensure that everything works:
rspec spec
rubycritic lib
To run the local documentation server:
yard server --reload
Create a new branch and start hacking:
git checkout -b my-contributions
Submit a pull request.
Author / License
Copyright (c) Michael van Rooijen ( @mrrooijen )
Released under the MIT License.