RememberMe

Gem Version Build Status Dependency Status Code Climate Coverage Status

RememberMe is a simple remember-me login solution on Rails. Manages generating and clearing a token for remembering the user from a saved cookie.

remember me

Installation

Add this line to your application's Gemfile:

gem 'remember_me'

And then execute:

$ bundle

Or install it yourself as:

$ gem install remember_me

Usage

controllers/application_controller.rb:

class ApplicationController < ActionController::Base
  include RememberMe::Controller
end

models/user.rb:

class User < ActiveRecord::Base
  include RememberMe::Model
end

if mongoid

class User
  include Mongoid::Document
  include RememberMe::Model
end

controllers/sessions_controller.rb:

class SessionsController < ApplicationController
  def create
    # ... authenticated ...

    self.current_user = @user
    remember_me(current_user) if remember_me?

    redirect_to root_path, notice: 'Success'
  end

  def destroy
    forget_me(current_user)
    self.current_user = nil
    redirect_to login_path, notice: 'Success'
  end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

License

MIT