devise_inactivatable 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +1 -0
- data/config/locales/en.yml +4 -0
- data/devise_inactivatable.gemspec +25 -0
- data/lib/devise/inactivatable/inactivatable.rb +3 -0
- data/lib/devise/inactivatable/model.rb +33 -0
- data/lib/devise/inactivatable/version.rb +3 -0
- data/lib/devise_inactivatable.rb +1 -0
- data/test/devise/inactivatable/inactivatable_test.rb +43 -0
- data/test/rails_app/.gitignore +15 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +3 -0
- data/test/rails_app/app/models/.gitkeep +0 -0
- data/test/rails_app/app/models/admin.rb +3 -0
- data/test/rails_app/app/models/user.rb +3 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +53 -0
- data/test/rails_app/config/boot.rb +6 -0
- data/test/rails_app/config/database.yml +7 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +28 -0
- data/test/rails_app/config/environments/production.rb +67 -0
- data/test/rails_app/config/environments/test.rb +32 -0
- data/test/rails_app/config/initializers/devise.rb +12 -0
- data/test/rails_app/db/migrate/20120508165529_create_tables.rb +77 -0
- data/test/support/assertions.rb +7 -0
- data/test/support/factories.rb +22 -0
- data/test/test_helper.rb +21 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb189bdcd26a52b06756bfe2ded95c185897900c
|
4
|
+
data.tar.gz: f038a4014d358e8d5bbe0e6a3c6e83f78d2584bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a682aad5f2e416e9cfcd7466afbdf4387c1d661ae2ffa1ac202bb268f48f36555cae4b05c95d6e37c7804625cbaf04aa016e5876125472a90b3ac84520f717a4
|
7
|
+
data.tar.gz: 8ec8c6cde703f3a3b74eda874c42a73393d304f86051749994491b08f6faa3dafaf931a62d986c5f0c1c38717f0d2e6de88c59fb86cccc592a75fb6ae716e28a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Agiltec
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# DeviseInactivatable
|
2
|
+
|
3
|
+
This is a simple, however wonderful devise extension to activate and inactivate users account.
|
4
|
+
It is was inspired by extension [devise_deactivatable](https://github.com/thickpaddy/devise_deactivatable).
|
5
|
+
Thanks to [Mark Woods](https://github.com/thickpaddy) by inspiration
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'devise_inactivatable'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install devise_inactivatable
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
u = User.create(:name => 'John Doe', :password => "john.doe")
|
24
|
+
u.inactive? # false
|
25
|
+
u.active_for_authentication? # true
|
26
|
+
u.inactive_message # :inactive
|
27
|
+
u.inactivate!
|
28
|
+
u.inactive? # true
|
29
|
+
u.active_for_authentication? # false
|
30
|
+
u.inactive_message # :inactivated
|
31
|
+
|
32
|
+
#### Using with ActiveRecord
|
33
|
+
You need to create a migration, manually (there is no magic here):
|
34
|
+
|
35
|
+
class DeviseInactivatableToUsers < ActiveRecord::Migration
|
36
|
+
def up
|
37
|
+
add_column :users, :inactivated_at, :timestamp
|
38
|
+
add_index :users, :inactivated_at
|
39
|
+
end
|
40
|
+
def down
|
41
|
+
remove_index :users, :inactivated_at
|
42
|
+
remove_column :users, :inactivated_at
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
Include in your model:
|
48
|
+
|
49
|
+
class User < ActiveRecord::Base
|
50
|
+
devise :database_authentication, :inactivatable
|
51
|
+
end
|
52
|
+
|
53
|
+
Adding four wonderful new methods, and modifications to two other methods:
|
54
|
+
|
55
|
+
- activate! : active the account if it is inactive
|
56
|
+
- inactivate! : inactive the account if it is active
|
57
|
+
- active? : checks whether the account is active
|
58
|
+
- inactive? : checks whether the account is inactive
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
The devise_inactivatable is hosted on Github: https://github.com/jonathanccalixto/devise_inactivable, where your contributions, forkings, comments and feedback are greatly welcomed.
|
63
|
+
|
64
|
+
Copyright (c) 2014-2014 Agiltec, released under the MIT license.
|
65
|
+
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it ( http://github.com/jonathanccalixto/devise_inactivatable/fork )
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devise/inactivatable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devise_inactivatable"
|
8
|
+
spec.version = DeviseInactivatable::VERSION
|
9
|
+
spec.authors = ["Jonathan C. Calixto"]
|
10
|
+
spec.email = ["jonathanccalixto@gmail.com"]
|
11
|
+
spec.summary = %q{Activate and inactivate a devise account }
|
12
|
+
spec.description = %q{This is a simple, however wonderful devise extension to activate and inactivate users account.}
|
13
|
+
spec.homepage = "https://github.com/jonathanccalixto/devise_inactivatable"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "devise", ">= 2.0"
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'devise/strategies/database_authenticatable'
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Models
|
5
|
+
module Inactivatable
|
6
|
+
|
7
|
+
def active_for_authentication?
|
8
|
+
active? && super
|
9
|
+
end
|
10
|
+
|
11
|
+
def inactivate!
|
12
|
+
touch :inactivated_at
|
13
|
+
end
|
14
|
+
|
15
|
+
def activate!
|
16
|
+
update_attribute :inactivated_at, nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def active?
|
20
|
+
!inactivated_at
|
21
|
+
end
|
22
|
+
|
23
|
+
def inactive?
|
24
|
+
!!inactivated_at
|
25
|
+
end
|
26
|
+
|
27
|
+
def inactive_message
|
28
|
+
inactive? ? :inactivated : super
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'devise/inactivatable/inactivatable'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class InactivatableTest < ActiveSupport::TestCase
|
4
|
+
include Support::Assertions
|
5
|
+
include Support::Factories
|
6
|
+
include Support::Swappers
|
7
|
+
|
8
|
+
def encrypt_password(admin, pepper=Admin.pepper, stretches=Admin.stretches, encryptor=Admin.encryptor_class)
|
9
|
+
encryptor.digest('123456', stretches, admin.password_salt, pepper)
|
10
|
+
end
|
11
|
+
|
12
|
+
test '#inactivated_at should be nil when admin created' do
|
13
|
+
assert_nil create_admin.inactivated_at
|
14
|
+
end
|
15
|
+
|
16
|
+
test '#inactivate! should set #inactivated_at' do
|
17
|
+
admin = create_admin
|
18
|
+
assert_not admin.inactivated_at.present?
|
19
|
+
admin.inactivate!
|
20
|
+
assert admin.inactivated_at.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
test '#activate! should set #inactivated_at with nil' do
|
24
|
+
admin = create_admin(:inactivated_at, Time.now)
|
25
|
+
assert admin.inactivated_at.present?
|
26
|
+
admin.inactivate!
|
27
|
+
assert_not admin.inactivated_at.present?
|
28
|
+
end
|
29
|
+
|
30
|
+
test '#active? should be true when actived' do
|
31
|
+
admin = create_admin(:inactivated_at, Time.now)
|
32
|
+
assert_not admin.active?
|
33
|
+
admin.activate!
|
34
|
+
assert admin.active?
|
35
|
+
end
|
36
|
+
|
37
|
+
test '#inactive? should be true when inactived' do
|
38
|
+
admin = create_admin
|
39
|
+
assert_not admin.inactive?
|
40
|
+
admin.inactivate!
|
41
|
+
assert admin.inactive?
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
RailsApp::Application.load_tasks
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
if defined?(Bundler)
|
6
|
+
# If you precompile assets before deploying to production, use this line
|
7
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
8
|
+
# If you want your assets lazily compiled in production, use this line
|
9
|
+
# Bundler.require(:default, :assets, Rails.env)
|
10
|
+
end
|
11
|
+
|
12
|
+
module RailsApp
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
|
42
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
43
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
44
|
+
# like if you have constraints or database-specific column types
|
45
|
+
# config.active_record.schema_format = :sql
|
46
|
+
|
47
|
+
# Enable the asset pipeline
|
48
|
+
config.assets.enabled = true
|
49
|
+
|
50
|
+
# Version of your assets, change this if you want to expire all your assets
|
51
|
+
config.assets.version = '1.0'
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
config.eager_load = false
|
9
|
+
|
10
|
+
# Show full error reports and disable caching
|
11
|
+
config.consider_all_requests_local = true
|
12
|
+
config.action_controller.perform_caching = false
|
13
|
+
|
14
|
+
# Don't care if the mailer can't send
|
15
|
+
config.action_mailer.raise_delivery_errors = false
|
16
|
+
|
17
|
+
# Print deprecation notices to the Rails logger
|
18
|
+
config.active_support.deprecation = :log
|
19
|
+
|
20
|
+
# Only use best-standards-support built into browsers
|
21
|
+
config.action_dispatch.best_standards_support = :builtin
|
22
|
+
|
23
|
+
# Do not compress assets
|
24
|
+
config.assets.compress = false
|
25
|
+
|
26
|
+
# Expands the lines which load the assets
|
27
|
+
config.assets.debug = true
|
28
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
39
|
+
# Use a different logger for distributed setups
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
|
+
|
42
|
+
# Use a different cache store in production
|
43
|
+
# config.cache_store = :mem_cache_store
|
44
|
+
|
45
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
47
|
+
|
48
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
+
# config.assets.precompile += %w( search.js )
|
50
|
+
|
51
|
+
# Disable delivery errors, bad email addresses will be ignored
|
52
|
+
# config.action_mailer.raise_delivery_errors = false
|
53
|
+
|
54
|
+
# Enable threaded mode
|
55
|
+
# config.threadsafe!
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation can not be found)
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Send deprecation notices to registered listeners
|
62
|
+
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Log the query plan for queries taking more than this (works
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
67
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
config.eager_load = false
|
10
|
+
|
11
|
+
# Configure static asset server for tests with Cache-Control for performance
|
12
|
+
config.serve_static_assets = true
|
13
|
+
config.static_cache_control = "public, max-age=3600"
|
14
|
+
|
15
|
+
# Show full error reports and disable caching
|
16
|
+
config.consider_all_requests_local = true
|
17
|
+
config.action_controller.perform_caching = false
|
18
|
+
|
19
|
+
# Raise exceptions instead of rendering exception templates
|
20
|
+
config.action_dispatch.show_exceptions = false
|
21
|
+
|
22
|
+
# Disable request forgery protection in test environment
|
23
|
+
config.action_controller.allow_forgery_protection = false
|
24
|
+
|
25
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
26
|
+
# The :test delivery method accumulates sent emails in the
|
27
|
+
# ActionMailer::Base.deliveries array.
|
28
|
+
config.action_mailer.delivery_method = :test
|
29
|
+
|
30
|
+
# Print deprecation notices to the stderr
|
31
|
+
config.active_support.deprecation = :stderr
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Devise.setup do |config|
|
2
|
+
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
3
|
+
|
4
|
+
require 'devise/orm/active_record'
|
5
|
+
|
6
|
+
config.case_insensitive_keys = [ :email ]
|
7
|
+
|
8
|
+
config.strip_whitespace_keys = [ :email ]
|
9
|
+
config.skip_session_storage = [:http_auth]
|
10
|
+
|
11
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
12
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class CreateTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :username
|
5
|
+
t.string :facebook_token
|
6
|
+
|
7
|
+
## Database authenticatable
|
8
|
+
t.string :email, :null => false, :default => ""
|
9
|
+
t.string :encrypted_password, :null => false, :default => ""
|
10
|
+
|
11
|
+
## Recoverable
|
12
|
+
t.string :reset_password_token
|
13
|
+
t.datetime :reset_password_sent_at
|
14
|
+
|
15
|
+
## Rememberable
|
16
|
+
t.datetime :remember_created_at
|
17
|
+
|
18
|
+
## Trackable
|
19
|
+
t.integer :sign_in_count, :default => 0
|
20
|
+
t.datetime :current_sign_in_at
|
21
|
+
t.datetime :last_sign_in_at
|
22
|
+
t.string :current_sign_in_ip
|
23
|
+
t.string :last_sign_in_ip
|
24
|
+
|
25
|
+
## Encryptable
|
26
|
+
# t.string :password_salt
|
27
|
+
|
28
|
+
## Confirmable
|
29
|
+
t.string :confirmation_token
|
30
|
+
t.datetime :confirmed_at
|
31
|
+
t.datetime :confirmation_sent_at
|
32
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
33
|
+
|
34
|
+
## Lockable
|
35
|
+
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
36
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
37
|
+
t.datetime :locked_at
|
38
|
+
|
39
|
+
## Token authenticatable
|
40
|
+
t.string :authentication_token
|
41
|
+
|
42
|
+
t.timestamps
|
43
|
+
end
|
44
|
+
|
45
|
+
create_table :admins do |t|
|
46
|
+
## Database authenticatable
|
47
|
+
t.string :email, :null => true
|
48
|
+
t.string :encrypted_password, :null => true
|
49
|
+
|
50
|
+
## Recoverable
|
51
|
+
t.string :reset_password_token
|
52
|
+
t.datetime :reset_password_sent_at
|
53
|
+
|
54
|
+
## Rememberable
|
55
|
+
t.datetime :remember_created_at
|
56
|
+
|
57
|
+
## Confirmable
|
58
|
+
t.string :confirmation_token
|
59
|
+
t.datetime :confirmed_at
|
60
|
+
t.datetime :confirmation_sent_at
|
61
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
62
|
+
|
63
|
+
## Encryptable
|
64
|
+
t.string :password_salt
|
65
|
+
|
66
|
+
## Lockable
|
67
|
+
t.datetime :locked_at
|
68
|
+
|
69
|
+
t.timestamps
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.down
|
74
|
+
drop_table :users
|
75
|
+
drop_table :admins
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Support
|
2
|
+
module Factories
|
3
|
+
def generate_unique_email
|
4
|
+
@@email_count ||= 0
|
5
|
+
@@email_count += 1
|
6
|
+
"test#{@@email_count}@example.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
def valid_attributes(attributes={})
|
10
|
+
{ :username => "usertest",
|
11
|
+
:email => generate_unique_email,
|
12
|
+
:password => '123456',
|
13
|
+
:password_confirmation => '123456' }.update(attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_admin(attributes={})
|
17
|
+
valid_attributes = valid_attributes(attributes)
|
18
|
+
valid_attributes.delete(:username)
|
19
|
+
Admin.create!(valid_attributes)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require "devise"
|
3
|
+
require "devise/version"
|
4
|
+
require "active_support/core_ext/module/attribute_accessors"
|
5
|
+
|
6
|
+
require "devise/inactivatable/inactivatable"
|
7
|
+
|
8
|
+
require "minitest/autorun"
|
9
|
+
require "minitest/unit"
|
10
|
+
|
11
|
+
require "mocha/setup"
|
12
|
+
|
13
|
+
require "rails_app/config/environment"
|
14
|
+
|
15
|
+
require 'support/assertions'
|
16
|
+
require 'support/factories'
|
17
|
+
|
18
|
+
ActiveRecord::Migration.verbose = false
|
19
|
+
ActiveRecord::Base.logger = Logger.new(nil)
|
20
|
+
|
21
|
+
ActiveRecord::Migrator.migrate(File.expand_path("test/rails_app/db/migrate"))
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_inactivatable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan C. Calixto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devise
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: This is a simple, however wonderful devise extension to activate and
|
56
|
+
inactivate users account.
|
57
|
+
email:
|
58
|
+
- jonathanccalixto@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- config/locales/en.yml
|
69
|
+
- devise_inactivatable.gemspec
|
70
|
+
- lib/devise/inactivatable/inactivatable.rb
|
71
|
+
- lib/devise/inactivatable/model.rb
|
72
|
+
- lib/devise/inactivatable/version.rb
|
73
|
+
- lib/devise_inactivatable.rb
|
74
|
+
- test/devise/inactivatable/inactivatable_test.rb
|
75
|
+
- test/rails_app/.gitignore
|
76
|
+
- test/rails_app/Rakefile
|
77
|
+
- test/rails_app/app/controllers/application_controller.rb
|
78
|
+
- test/rails_app/app/models/.gitkeep
|
79
|
+
- test/rails_app/app/models/admin.rb
|
80
|
+
- test/rails_app/app/models/user.rb
|
81
|
+
- test/rails_app/config.ru
|
82
|
+
- test/rails_app/config/application.rb
|
83
|
+
- test/rails_app/config/boot.rb
|
84
|
+
- test/rails_app/config/database.yml
|
85
|
+
- test/rails_app/config/environment.rb
|
86
|
+
- test/rails_app/config/environments/development.rb
|
87
|
+
- test/rails_app/config/environments/production.rb
|
88
|
+
- test/rails_app/config/environments/test.rb
|
89
|
+
- test/rails_app/config/initializers/devise.rb
|
90
|
+
- test/rails_app/db/migrate/20120508165529_create_tables.rb
|
91
|
+
- test/support/assertions.rb
|
92
|
+
- test/support/factories.rb
|
93
|
+
- test/test_helper.rb
|
94
|
+
homepage: https://github.com/jonathanccalixto/devise_inactivatable
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.2.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Activate and inactivate a devise account
|
118
|
+
test_files: []
|