No release in over 3 years
Low commit activity in last 3 years
This is a simple, however wonderful devise extension to activate and inactivate users account.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0

Runtime

>= 2.0
 Project Readme

DeviseInactivatable

This is a simple, however wonderful devise extension to activate and inactivate users account. It is was inspired by extension devise_deactivatable. Thanks to Mark Woods by inspiration

Installation

Add this line to your application's Gemfile:

gem 'devise_inactivatable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install devise_inactivatable

Usage

u = User.create(:name => 'John Doe', :password => "john.doe")
u.inactive? # false
u.active_for_authentication? # true
u.inactive_message # :inactive
u.inactivate!
u.inactive? # true
u.active_for_authentication? # false
u.inactive_message # :inactivated

Using with ActiveRecord

You need to create a migration, manually (there is no magic here):

class DeviseInactivatableToUsers < ActiveRecord::Migration
  def up
    add_column :users, :inactivated_at, :timestamp
    add_index :users, :inactivated_at
  end
  def down
    remove_index :users, :inactivated_at
    remove_column :users, :inactivated_at
  end
end

Include in your model:

class User < ActiveRecord::Base
  devise :database_authentication, :inactivatable
end

Adding four wonderful new methods:

  • activate! : active the account if it is inactive
  • inactivate! : inactive the account if it is active
  • active? : checks whether the account is active
  • inactive? : checks whether the account is inactive

And modifications to two other methods:

  • active_for_authentication? : If inactive returns false, else it preforms the super method
  • inactive_message : If inactive returns :inactivated, else it performs the super method

License

The devise_inactivatable is hosted on Github: https://github.com/jonathanccalixto/devise_inactivable, where your contributions, forkings, comments and feedback are greatly welcomed.

Copyright (c) 2014-2014 Agiltec, released under the MIT license.

Contributing

  1. Fork it ( http://github.com/jonathanccalixto/devise_inactivatable/fork )
  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