devise_approvable 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +80 -0
- data/README +5 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/app/controllers/approvals_controller.rb +14 -0
- data/app/views/devise/approvals/new.html.erb +16 -0
- data/config/initializers/devise.rb +110 -0
- data/devise-approvable.gemspec +68 -0
- data/lib/approvable_mailer.rb +11 -0
- data/lib/devise_approvable/mailer.rb +11 -0
- data/lib/devise_approvable/model.rb +95 -0
- data/lib/devise_approvable/routes.rb +9 -0
- data/lib/devise_approvable/version.rb +3 -0
- data/lib/devise_approvable.rb +16 -0
- data/test/approvable_test.rb +0 -0
- data/views/devise_mailer/approval_instructions.html.erb +11 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d6ee7a4c4b50dbb8c69b5f55a2920eac5e5d5c64
|
4
|
+
data.tar.gz: ff50c8cd9811d6219464551e92a56e7bb53eb281
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec15da36a1e2d754b58eaabbd6e081b90d9baf040ba38c0d2fe538ebbc9ace11868732113cc3f3d91e4e93b4073063fce6e236d5c8d9227aa9ff69f233cfc1f8
|
7
|
+
data.tar.gz: 0d4cbc97f16bad9f156515661939fd5758c3503d4dafdc7b34ec5daadfab5a841e70770692fe440f17ca0870e7a68a58190ba2cad5e189387474ac92b54ecf33
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.2.1)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.8)
|
11
|
+
builder (3.2.2)
|
12
|
+
descendants_tracker (0.0.4)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
+
docile (1.1.5)
|
15
|
+
faraday (0.9.1)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
git (1.2.9.1)
|
18
|
+
github_api (0.12.3)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
descendants_tracker (~> 0.0.4)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 3.3)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
nokogiri (~> 1.6.3)
|
25
|
+
oauth2
|
26
|
+
hashie (3.4.1)
|
27
|
+
highline (1.7.1)
|
28
|
+
i18n (0.7.0)
|
29
|
+
jeweler (2.0.1)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.0)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
json (1.8.2)
|
39
|
+
jwt (1.4.1)
|
40
|
+
mini_portile (0.6.2)
|
41
|
+
minitest (5.5.1)
|
42
|
+
multi_json (1.11.0)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.6.6.2)
|
46
|
+
mini_portile (~> 0.6.0)
|
47
|
+
oauth2 (1.0.0)
|
48
|
+
faraday (>= 0.8, < 0.10)
|
49
|
+
jwt (~> 1.0)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (~> 1.2)
|
53
|
+
rack (1.6.0)
|
54
|
+
rake (10.4.2)
|
55
|
+
rdoc (3.12.2)
|
56
|
+
json (~> 1.4)
|
57
|
+
shoulda (3.5.0)
|
58
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
59
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
60
|
+
shoulda-context (1.2.1)
|
61
|
+
shoulda-matchers (2.8.0)
|
62
|
+
activesupport (>= 3.0.0)
|
63
|
+
simplecov (0.9.2)
|
64
|
+
docile (~> 1.1.0)
|
65
|
+
multi_json (~> 1.0)
|
66
|
+
simplecov-html (~> 0.9.0)
|
67
|
+
simplecov-html (0.9.0)
|
68
|
+
thread_safe (0.3.5)
|
69
|
+
tzinfo (1.2.2)
|
70
|
+
thread_safe (~> 0.1)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
bundler (~> 1.0)
|
77
|
+
jeweler (~> 2.0.1)
|
78
|
+
rdoc (~> 3.12)
|
79
|
+
shoulda
|
80
|
+
simplecov
|
data/README
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
An approvable module. This includes all confirmable functions as approval should happen before confirmation.
|
2
|
+
|
3
|
+
Workflow:
|
4
|
+
|
5
|
+
Admin email should be added to the configuration. When user signs up admin receives email with link to approve user. Admin clicks link with token. User is approved. Confirmation email gets sent to user. User clicks confirmation link. Profit.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "devise_approvable"
|
18
|
+
gem.homepage = "http://github.com/eggie5/devise-approvable"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Oh so perfect}
|
21
|
+
gem.description = %Q{adds feature to devise}
|
22
|
+
gem.email = "eggie5@gmail.com"
|
23
|
+
gem.authors = ["Alex Egg"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "devise-approvable #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Devise::ApprovalsController < DeviseController
|
2
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
3
|
+
def show
|
4
|
+
self.resource = resource_class.approve_by_token(params[:approval_token])
|
5
|
+
yield resource if block_given?
|
6
|
+
|
7
|
+
if resource.errors.empty?
|
8
|
+
set_flash_message(:notice, :approved) if is_flashing_format?
|
9
|
+
respond_with_navigational(resource){ redirect_to after_approval_path_for(resource_name, resource) }
|
10
|
+
else
|
11
|
+
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2>Dev Account Approval</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, as: resource_name, url: approval_path(resource_name), html: { method: :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="actions">
|
12
|
+
<%= f.submit "Resend confirmation instructions" %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'devise/approvable_mailer'
|
2
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
3
|
+
# four configuration values can also be set straight in your models.
|
4
|
+
Devise.setup do |config|
|
5
|
+
# Configure the e-mail address which will be shown in DeviseMailer.
|
6
|
+
config.mailer_sender = "support@yoursite.ca" # .CA because clearly you're Canadian
|
7
|
+
config.approval_recepient = "admin@yourcandaiansite.ca"
|
8
|
+
|
9
|
+
# Configure the content type of DeviseMailer mails (defaults to text/html")
|
10
|
+
# config.mailer_content_type = "text/plain"
|
11
|
+
|
12
|
+
# ==> Configuration for :authenticatable
|
13
|
+
# Invoke `rake secret` and use the printed value to setup a pepper to generate
|
14
|
+
# the encrypted password. By default no pepper is used.
|
15
|
+
# config.pepper = "rake secret output"
|
16
|
+
|
17
|
+
# Configure how many times you want the password is reencrypted. Default is 10.
|
18
|
+
# config.stretches = 10
|
19
|
+
|
20
|
+
# Define which will be the encryption algorithm. Supported algorithms are :sha1
|
21
|
+
# (default), :sha512 and :bcrypt. Devise also supports encryptors from others
|
22
|
+
# authentication tools as :clearance_sha1, :authlogic_sha512 (then you should set
|
23
|
+
# stretches above to 20 for default behavior) and :restful_authentication_sha1
|
24
|
+
# (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
|
25
|
+
# config.encryptor = :sha1
|
26
|
+
|
27
|
+
# Configure which keys are used when authenticating an user. By default is
|
28
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
29
|
+
# authenticating an user, both parameters are required. Remember that those
|
30
|
+
# parameters are used only when authenticating and not when retrieving from
|
31
|
+
# session. If you need permissions, you should implement that in a before filter.
|
32
|
+
# config.authentication_keys = [ :email ]
|
33
|
+
|
34
|
+
# The realm used in Http Basic Authentication
|
35
|
+
# config.http_authentication_realm = "Application"
|
36
|
+
|
37
|
+
# ==> Configuration for :confirmable
|
38
|
+
# The time you want give to your user to confirm his account. During this time
|
39
|
+
# he will be able to access your application without confirming. Default is nil.
|
40
|
+
# config.confirm_within = 2.days
|
41
|
+
|
42
|
+
# ==> Configuration for :rememberable
|
43
|
+
# The time the user will be remembered without asking for credentials again.
|
44
|
+
# config.remember_for = 2.weeks
|
45
|
+
|
46
|
+
# ==> Configuration for :timeoutable
|
47
|
+
# The time you want to timeout the user session without activity. After this
|
48
|
+
# time the user will be asked for credentials again.
|
49
|
+
# config.timeout_in = 10.minutes
|
50
|
+
|
51
|
+
# ==> Configuration for :lockable
|
52
|
+
# Number of authentication tries before locking an account.
|
53
|
+
# config.maximum_attempts = 20
|
54
|
+
|
55
|
+
# Defines which strategy will be used to unlock an account.
|
56
|
+
# :email = Sends an unlock link to the user email
|
57
|
+
# :time = Reanables login after a certain ammount of time (see :unlock_in below)
|
58
|
+
# :both = enables both strategies
|
59
|
+
# config.unlock_strategy = :both
|
60
|
+
|
61
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
62
|
+
# config.unlock_in = 1.hour
|
63
|
+
|
64
|
+
# ==> Configuration for :token_authenticatable
|
65
|
+
# Defines name of the authentication token params key
|
66
|
+
# config.token_authentication_key = :auth_token
|
67
|
+
|
68
|
+
# ==> General configuration
|
69
|
+
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper
|
70
|
+
# (requires mongo_ext installed) and :data_mapper (experimental).
|
71
|
+
# require 'devise/orm/mongo_mapper'
|
72
|
+
# config.orm = :mongo_mapper
|
73
|
+
|
74
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
75
|
+
# "sessions/users/new". It's turned off by default because it's slower if you
|
76
|
+
# are using only default views.
|
77
|
+
# config.scoped_views = true
|
78
|
+
|
79
|
+
# By default, devise detects the role accessed based on the url. So whenever
|
80
|
+
# accessing "/users/sign_in", it knows you are accessing an User. This makes
|
81
|
+
# routes as "/sign_in" not possible, unless you tell Devise to use the default
|
82
|
+
# scope, setting true below.
|
83
|
+
config.use_default_scope = true
|
84
|
+
|
85
|
+
# Configure the default scope used by Devise. By default it's the first devise
|
86
|
+
# role declared in your routes.
|
87
|
+
config.default_scope = :user
|
88
|
+
|
89
|
+
# If you want to use other strategies, that are not (yet) supported by Devise,
|
90
|
+
# you can configure them inside the config.warden block. The example below
|
91
|
+
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
92
|
+
#
|
93
|
+
# config.warden do |manager|
|
94
|
+
# manager.oauth(:twitter) do |twitter|
|
95
|
+
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
|
96
|
+
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
97
|
+
# twitter.options :site => 'http://twitter.com'
|
98
|
+
# end
|
99
|
+
# manager.default_strategies.unshift :twitter_oauth
|
100
|
+
# end
|
101
|
+
|
102
|
+
# Configure default_url_options if you are using dynamic segments in :path_prefix
|
103
|
+
# for devise_for.
|
104
|
+
# config.default_url_options do
|
105
|
+
# { :locale => I18n.locale }
|
106
|
+
# end
|
107
|
+
|
108
|
+
config.add_module(:approvable, :model => 'devise/approvable')
|
109
|
+
config.add_module(:approvable_email, :model => 'devise/approvable_mailer')
|
110
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: devise-approvable 0.3.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "devise_approvable"
|
9
|
+
s.version = "0.3.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Alex Egg"]
|
14
|
+
s.date = "2015-04-06"
|
15
|
+
s.description = "adds feature to devise"
|
16
|
+
s.email = "eggie5@gmail.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"README",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"app/controllers/approvals_controller.rb",
|
27
|
+
"app/views/devise/approvals/new.html.erb",
|
28
|
+
"config/initializers/devise.rb",
|
29
|
+
"devise-approvable.gemspec",
|
30
|
+
"lib/approvable_mailer.rb",
|
31
|
+
"lib/devise_approvable.rb",
|
32
|
+
"lib/devise_approvable/mailer.rb",
|
33
|
+
"lib/devise_approvable/model.rb",
|
34
|
+
"lib/devise_approvable/routes.rb",
|
35
|
+
"lib/devise_approvable/version.rb",
|
36
|
+
"test/approvable_test.rb",
|
37
|
+
"views/devise_mailer/approval_instructions.html.erb"
|
38
|
+
]
|
39
|
+
s.homepage = "http://github.com/eggie5/devise-approvable"
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.rubygems_version = "2.2.1"
|
42
|
+
s.summary = "Oh so perfect"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 4
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
52
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
58
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
65
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module Approvable
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
puts "Devise::Models::Approvable module injected into #{self.class} class"
|
7
|
+
|
8
|
+
base.class_eval do
|
9
|
+
extend ClassMethods
|
10
|
+
|
11
|
+
before_create :generate_approval_token, :if => :approval_required?
|
12
|
+
after_create :send_approval_instructions, :unless => :approved?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#override
|
17
|
+
def active_for_authentication?
|
18
|
+
super && approved?
|
19
|
+
end
|
20
|
+
|
21
|
+
#override
|
22
|
+
def inactive_message
|
23
|
+
if !approved?
|
24
|
+
:not_approved
|
25
|
+
else
|
26
|
+
super # Use whatever other message
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def approve!
|
32
|
+
self.approved_at = Time.now.utc
|
33
|
+
self.approval_token = nil
|
34
|
+
save(:validate => false)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Verifies whether a user is confirmed or not
|
38
|
+
def approved?
|
39
|
+
!!self.approved_at
|
40
|
+
end
|
41
|
+
|
42
|
+
def skip_approval!
|
43
|
+
self.approved_at = Time.now.utc
|
44
|
+
@skip_approval = true
|
45
|
+
end
|
46
|
+
|
47
|
+
# Send approval instructions by email
|
48
|
+
def send_approval_instructions
|
49
|
+
unless @raw_approval_token
|
50
|
+
generate_approval_token!
|
51
|
+
end
|
52
|
+
|
53
|
+
opts = { to: "dev-approvals@curbcall.com" }
|
54
|
+
send_devise_notification(:approval_instructions, @raw_approval_token, opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
protected
|
59
|
+
def approval_required?
|
60
|
+
!@skip_approval
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_approval_token!
|
64
|
+
generate_approval_token && save(validate: false)
|
65
|
+
end
|
66
|
+
|
67
|
+
def generate_approval_token
|
68
|
+
raw, enc = Devise.token_generator.generate(self.class, :approval_token)
|
69
|
+
@raw_approval_token = raw
|
70
|
+
self.approval_token = enc
|
71
|
+
self.approval_sent_at = Time.now.utc
|
72
|
+
end
|
73
|
+
|
74
|
+
module ClassMethods
|
75
|
+
# Find a user by its approvable token and try to approve it.
|
76
|
+
# If no user is found, returns a new user with an error.
|
77
|
+
# If the user is already approved, create an error for the user
|
78
|
+
# Options must have the approval_token
|
79
|
+
def approve_by_token(approval_token)
|
80
|
+
original_token = approval_token
|
81
|
+
approval_token = Devise.token_generator.digest(self, :approval_token, approval_token)
|
82
|
+
|
83
|
+
approvable = find_or_initialize_with_error_by(:approval_token, approval_token)
|
84
|
+
approvable.approve! if approvable.persisted?
|
85
|
+
approvable.approval_token = original_token
|
86
|
+
approvable
|
87
|
+
end
|
88
|
+
|
89
|
+
Devise::Models.config(self, :approver_class)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Devise.add_module :approvable, :model => 'approvable'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
p "Loading Devise Approvable"
|
2
|
+
|
3
|
+
module DeviseApprovable
|
4
|
+
autoload :Mailer, 'devise_approvable/mailer'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'devise'
|
8
|
+
require 'devise_approvable/routes'
|
9
|
+
# require 'devise_approvable/rails'
|
10
|
+
|
11
|
+
module Devise
|
12
|
+
mattr_accessor :admin_email
|
13
|
+
@@admin_email = "admin@curbcall.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
Devise.add_module :approvable, :controller => :approvals, :model => 'devise_approvable/model', :route => {:approval => [nil, :new, :accept, :show]}
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<p>Someone has registered for a membership.</p>
|
2
|
+
|
3
|
+
<p>Details:
|
4
|
+
<%= "<br />First Name: #{@resource.first_name}" if !@resource.first_name.nil? %>
|
5
|
+
<%= "<br />Last Name: #{@resource.last_name}" if !@resource.last_name.nil? %>
|
6
|
+
<%= "<br />E-Mail: #{@resource.email}" if !@resource.email.nil? %>
|
7
|
+
<%= "<br />Phone Number: #{@resource.phone}" if !@resource.phone.nil? %>
|
8
|
+
<%= "<br />Bio: #{@resource.bio}" if !@resource.bio.nil? %>
|
9
|
+
|
10
|
+
<p>If you would like to approve this person click the following link. Clicking the link will approve the new user and send the user a confirmation email.</p>
|
11
|
+
<p><%= link_to "Approve account for #{@resource.email} #{approvals_url(@resource.approval_token)}", approvals_url(@resource.approval_token) %></p>
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_approvable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Egg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shoulda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: adds feature to devise
|
84
|
+
email: eggie5@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- README
|
89
|
+
files:
|
90
|
+
- Gemfile
|
91
|
+
- Gemfile.lock
|
92
|
+
- README
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- app/controllers/approvals_controller.rb
|
96
|
+
- app/views/devise/approvals/new.html.erb
|
97
|
+
- config/initializers/devise.rb
|
98
|
+
- devise-approvable.gemspec
|
99
|
+
- lib/approvable_mailer.rb
|
100
|
+
- lib/devise_approvable.rb
|
101
|
+
- lib/devise_approvable/mailer.rb
|
102
|
+
- lib/devise_approvable/model.rb
|
103
|
+
- lib/devise_approvable/routes.rb
|
104
|
+
- lib/devise_approvable/version.rb
|
105
|
+
- test/approvable_test.rb
|
106
|
+
- views/devise_mailer/approval_instructions.html.erb
|
107
|
+
homepage: http://github.com/eggie5/devise-approvable
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.2.1
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Oh so perfect
|
131
|
+
test_files: []
|