# TinyAuth A utility for minimal user authentication. ## Installation Add this line to your application's Gemfile: ```ruby gem 'tiny_auth' ``` And then execute: $ bundle ## Usage First, create a table to store your users: ```ruby create_table :users do |t| t.string :email, null: false t.string :password_digest, null: false t.string :reset_token t.datetime :reset_token_expires_at t.index :email, unique: true t.index :reset_token, unique: true end ``` Your model should look like this: ```ruby class User < ApplicationRecord has_secure_password end ``` Now, you're ready to use `TinyAuth`: ```ruby auth = TinyAuth.new(User) user = auth.find_by_email('user@example.com') user = auth.find_by_credentials('user@example.com', 'password') token = auth.generate_token(user) user = auth.find_by_token(token) reset_token = auth.generate_reset_token(user) user = auth.exchange_reset_token(user, password: "changed") ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tiny_auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the TinyAuth project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tiny_auth/blob/master/CODE_OF_CONDUCT.md).