https://github.com/sixarm/sixarm_ruby_password_attribute
SixArm.com » Ruby » PasswordAttribute module to add BCrypt to an ActiveRecord model
https://github.com/sixarm/sixarm_ruby_password_attribute
authentication gem password ruby security
Last synced: over 1 year ago
JSON representation
SixArm.com » Ruby » PasswordAttribute module to add BCrypt to an ActiveRecord model
- Host: GitHub
- URL: https://github.com/sixarm/sixarm_ruby_password_attribute
- Owner: SixArm
- License: other
- Created: 2010-05-24T00:00:47.000Z (about 16 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T19:28:43.000Z (almost 3 years ago)
- Last Synced: 2025-02-06T00:24:46.179Z (over 1 year ago)
- Topics: authentication, gem, password, ruby, security
- Language: Ruby
- Homepage: http://sixarm.com
- Size: 315 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SixArm.com » Ruby » PasswordAttribute module to add strong passwords to ActiveRecord
[](http://badge.fury.io/rb/sixarm_ruby_password_attribute)
[](https://travis-ci.org/SixArm/sixarm_ruby_password_attribute)
[](https://codeclimate.com/github/SixArm/sixarm_ruby_password_attribute/maintainability)
* Git:
* Doc:
* Gem:
* Contact: Joel Parker Henderson,
* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).
## Introduction
Easy way to add BCrypt strong password capability to an ActiveRecord model.
This is typically useful to add to a Ruby On Rails ActiveRecord user model.
For docs go to
Want to help? We're happy to get pull requests.
## Install
### Gem
To install this gem in your shell or terminal:
gem install sixarm_ruby_password_attribute
### Gemfile
To add this gem to your Gemfile:
gem 'sixarm_ruby_password_attribute'
### Require
To require the gem in your code:
require 'sixarm_ruby_password_attribute'
## Examples
Include:
require 'sixarm_ruby_password_attribute'
class User
include PasswordAttribute
end
Create new user:
user=User.new
user.password='secret' # automatically converts plain text to bcrypt
user.save
Is a user's password valid?
if user.password=='secret'
# password is valid
else
# password is invalid
end
u.password='secret'
=> user's password is now secret
u.password=='secret'
=> true
u.password=='xxx'
=> false