mtdevise 3.8.4 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +2 -2
- data/README.md +16 -14
- data/Rakefile +12 -11
- data/app/extenders/controllers/application_controller_extender.rb +5 -5
- data/app/extenders/mtdevise/constraints/subdomain_required.rb +12 -0
- data/app/helpers/mtdevise/application_helper.rb +23 -23
- data/app/mailers/mtdevise/application_mailer.rb +2 -0
- data/app/models/concerns/mtdevise/user_storage.rb +11 -11
- data/app/models/mtdevise/account.rb +46 -46
- data/app/models/mtdevise/application_record.rb +3 -3
- data/app/models/mtdevise/member.rb +7 -7
- data/app/models/mtdevise/user.rb +17 -17
- data/config/initializers/assets.rb +1 -10
- data/config/initializers/devise.rb +274 -274
- data/config/initializers/devise/strategies/subdomain.rb +21 -20
- data/db/migrate/20150426071228_create_mtdevise_accounts.rb +9 -7
- data/db/migrate/20150426115631_add_owner_id_to_mtdevise_accounts.rb +6 -4
- data/db/migrate/20150426115910_create_mtdevise_users.rb +10 -8
- data/db/migrate/20150426143800_add_devise_to_mtdevise_users.rb +48 -46
- data/db/migrate/20150427200506_add_subdomain_to_mtdevise_accounts.rb +7 -5
- data/db/migrate/20150428110406_create_mtdevise_members.rb +10 -8
- data/db/migrate/20150504181830_add_confirmed_at_to_users.rb +9 -7
- data/db/migrate/20150719125100_add_authentication_token_to_mtdevise_users.rb +7 -5
- data/db/migrate/20151231043439_add_firstname_to_mtdevise_accounts.rb +8 -6
- data/lib/generators/mtdevise/views_generator.rb +57 -56
- data/lib/mtdevise.rb +0 -1
- data/lib/mtdevise/active_record_extensions.rb +12 -12
- data/lib/mtdevise/engine.rb +33 -31
- data/lib/mtdevise/scoped_to.rb +6 -6
- data/lib/mtdevise/version.rb +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +5 -3
- metadata +22 -40
- data/app/assets/mtdevise/constraints/subdomain_required.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f5dd0a4c809967eedcc685d40d84ba162c6b850
|
4
|
+
data.tar.gz: 2925f926e5b624ce6bf9415e551eec47c2bfbba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce2a6dd7421bb263018445918e2bfee3b7a21c40ada3af0fdc9fa9ce1e5e8cf68a87546d7b71d0761e1dd948c2bc6960fe737940354ac0fd52a37d5239cb2b9
|
7
|
+
data.tar.gz: 2fdf75d312eee978f694a25c3c27b382616930cd1f7b60d35d2eb6813cab18f530594324351d573a4c67bb7d6cb9ba6d14a94d78d05ebf3b66d1ab7d1165f1bf
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2016 BradPotts - PHCNetworks
|
1
|
+
Copyright 2016-2017 BradPotts - PHCNetworks
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,16 +4,16 @@
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/mtdevise.svg)](https://badge.fury.io/rb/mtdevise)
|
5
5
|
|
6
6
|
### Mtdevise(3) (MultiTenancyDevise) Documentation
|
7
|
-
PHC mtdevise gem adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom
|
8
|
-
|
9
|
-
* Multi-tenancy using subdomain scoping and account_id column.
|
7
|
+
PHC mtdevise gem adds multi-tenant and account management features to rails Devise gem. Plataformatec Devise and required custom Bootstrap Devise views included.
|
8
|
+
|
9
|
+
* Multi-tenancy using subdomain scoping and account_id column.
|
10
10
|
* Adds basecamp style logins to devise authentication gem.
|
11
|
-
* Welcome, Dashboard with custom Devise
|
11
|
+
* Welcome, Dashboard with custom Devise views included.
|
12
12
|
* Highly customizable views and layouts using standard bootstrap 3 code.
|
13
|
-
* Central login screen for all tenants (users) or logins through subdomain.
|
14
|
-
* Mis-Spelling and redirect to welcome screen if subdomain none-existent.
|
15
|
-
* Compatible with postgre, mysql and sqlite (for dev environments)
|
16
|
-
|
13
|
+
* Central login screen for all tenants (users) or logins through a subdomain.
|
14
|
+
* Mis-Spelling and redirect to welcome screen if subdomain none-existent.
|
15
|
+
* Compatible with postgre, mysql and sqlite (for dev environments).
|
16
|
+
|
17
17
|
#### Step 1 - Add user model to your app (Must be Done First!!)
|
18
18
|
Generate a user.rb file in your mainapp and add the code below
|
19
19
|
|
@@ -26,21 +26,22 @@ Generate a user.rb file in your mainapp and add the code below
|
|
26
26
|
bundle exec install
|
27
27
|
|
28
28
|
#### Step 3 - Add and migrate mtdevise database tables
|
29
|
+
|
29
30
|
rake railties:install:migrations
|
30
31
|
rake db:migrate
|
31
32
|
|
32
33
|
#### Step 4 - Configure ActionMailer
|
33
34
|
* Mailer functions are required in order for mtdevise to operate.
|
34
35
|
* Mailer is used for confirmation and password reset functions.
|
35
|
-
|
36
|
+
|
36
37
|
#### Step 5 - Mount the Engine in your Routes File
|
37
38
|
Add this line at the end of the routes file.
|
38
39
|
|
39
40
|
mount Mtdevise::Engine, :at => '/'
|
40
|
-
|
41
|
+
|
41
42
|
#### Step 6 - Constrain the routs you want secured
|
42
43
|
All the routes you want to have multi-tenacy login functions goes in between the constraints block.
|
43
|
-
|
44
|
+
|
44
45
|
constraints(Mtdevise::Constraints::SubdomainRequired) do
|
45
46
|
# Routes Requiring Security & Multi-Tenancy Routes
|
46
47
|
end
|
@@ -73,9 +74,9 @@ Set a sent from email address for confirmation and password reset emails [more i
|
|
73
74
|
#### Views - Mtdevise Views Can be Customized
|
74
75
|
Once installed views can be generated and customized to your apps needs.
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
rails generate mtdevise:views
|
78
|
+
rake assets:clobber
|
79
|
+
rake assets:precompile
|
79
80
|
|
80
81
|
#### Having troubles ?
|
81
82
|
[Multi-Tenant Starter App](https://github.com/PHCNetworks/multi-tenancy-starter-devise)
|
@@ -86,3 +87,4 @@ Once installed views can be generated and customized to your apps needs.
|
|
86
87
|
[Managed by PHCNetworks](http://phcnetworks.net)
|
87
88
|
|
88
89
|
[![Circle CI](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master.svg?style=svg)](https://circleci.com/gh/PHCNetworks/multi-tenancy-devise/tree/master)
|
90
|
+
|
data/Rakefile
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
begin
|
2
|
-
|
2
|
+
require 'bundler/setup'
|
3
3
|
|
4
4
|
rescue LoadError
|
5
|
-
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
7
|
|
8
8
|
require 'rdoc/task'
|
9
9
|
|
10
10
|
RDoc::Task.new(:rdoc) do |rdoc|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
rdoc.rdoc_dir = 'rdoc'
|
12
|
+
rdoc.title = 'Mtdevise'
|
13
|
+
rdoc.options << '--line-numbers'
|
14
|
+
rdoc.rdoc_files.include('README.md')
|
15
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
16
|
end
|
17
17
|
|
18
18
|
APP_RAKEFILE = File.expand_path("../spec/testapp/Rakefile", __FILE__)
|
19
|
+
|
19
20
|
load 'rails/tasks/engine.rake'
|
20
21
|
load 'rails/tasks/statistics.rake'
|
21
22
|
|
@@ -23,10 +24,10 @@ require 'bundler/gem_tasks'
|
|
23
24
|
require 'rake/testtask'
|
24
25
|
|
25
26
|
Rake::TestTask.new(:test) do |t|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
30
31
|
end
|
31
32
|
|
32
33
|
task default: :test
|
@@ -1,9 +1,9 @@
|
|
1
1
|
::ApplicationController.class_eval do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
# Current Account Helper
|
4
|
+
def current_account
|
5
|
+
@current_account ||= env['Houser-Object']
|
6
|
+
end
|
7
|
+
helper_method :current_account
|
8
8
|
|
9
9
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
module Mtdevise
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
# Helper for Page Title
|
5
|
+
def phc_title(phc_page_title)
|
6
|
+
content_for :phc_title, phc_page_title.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
# Helper for Page Title Tag
|
10
|
+
def phc_title_tagline(phc_page_title_tagline)
|
11
|
+
content_for :phc_title_tagline, phc_page_title_tagline.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
# Bootstrap Notification System
|
15
|
+
def flash_class(level)
|
16
|
+
case level.to_sym
|
17
|
+
when :notice then "alert alert-info"
|
18
|
+
when :success then "alert alert-success"
|
19
|
+
when :error then "alert alert-danger"
|
20
|
+
when :alert then "alert alert-warning"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
25
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Mtdevise
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
module UserStorage
|
3
|
+
|
4
|
+
# Extend Additional Account Support
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# Find User Table
|
8
|
+
included do
|
9
|
+
self.table_name = "mtdevise_users"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
13
|
end
|
@@ -1,48 +1,48 @@
|
|
1
1
|
module Mtdevise
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
2
|
+
class Account < ActiveRecord::Base
|
3
|
+
|
4
|
+
# Relationships
|
5
|
+
belongs_to :owner, :class_name => "Mtdevise::User"
|
6
|
+
has_many :members, :class_name => "Mtdevise::Member"
|
7
|
+
has_many :users, :through => :members
|
8
|
+
|
9
|
+
accepts_nested_attributes_for :owner
|
10
|
+
|
11
|
+
# Form Validations
|
12
|
+
validates :subdomain,
|
13
|
+
presence: true,
|
14
|
+
uniqueness: true,
|
15
|
+
format: { with: /\A[\w\-]+\Z/i, message: 'is not allowed. Please choose another subdomain.'},
|
16
|
+
exclusion: { in: %w(admin), message: 'is not allowed. Please choose another subdomain.'}
|
17
|
+
|
18
|
+
validates :name,
|
19
|
+
presence: true,
|
20
|
+
uniqueness: {scope: :owner_id}
|
21
|
+
|
22
|
+
validates :firstname,
|
23
|
+
presence: true
|
24
|
+
|
25
|
+
validates :lastname,
|
26
|
+
presence: true
|
27
|
+
|
28
|
+
validates :username,
|
29
|
+
presence: true,
|
30
|
+
uniqueness: true
|
31
|
+
|
32
|
+
before_validation do
|
33
|
+
self.subdomain = subdomain.to_s.downcase
|
34
|
+
self.username = username.to_s.downcase
|
35
|
+
end
|
36
|
+
|
37
|
+
# Define Account/Owner for User
|
38
|
+
def self.create_with_owner(params={})
|
39
|
+
account = new(params)
|
40
|
+
if account.save
|
41
|
+
account.users << account.owner
|
42
|
+
account.owner.confirm
|
43
|
+
end
|
44
|
+
account
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
48
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Mtdevise
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Member < ActiveRecord::Base
|
3
|
+
|
4
|
+
# Relationships
|
5
|
+
belongs_to :account, :class_name => "Mtdevise::Account"
|
6
|
+
belongs_to :user, :class_name => "Mtdevise::User"
|
7
|
+
|
8
|
+
end
|
9
9
|
end
|
data/app/models/mtdevise/user.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Mtdevise
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
2
|
+
class User < ::User
|
3
|
+
|
4
|
+
# Gravatar Support
|
5
|
+
include Gravtastic
|
6
|
+
gravtastic
|
7
|
+
|
8
|
+
# User API Tokens
|
9
|
+
acts_as_token_authenticatable
|
10
|
+
|
11
|
+
|
12
|
+
# Relationship
|
13
|
+
has_many :accounts, :class_name => "Mtdevise::Account", :foreign_key => "owner_id"
|
14
|
+
|
15
|
+
# Define Devise
|
16
|
+
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
|
17
|
+
|
18
|
+
end
|
19
19
|
end
|
@@ -1,11 +1,2 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Version of your assets, change this if you want to expire all your assets.
|
4
1
|
Rails.application.config.assets.version = '1.0'
|
5
|
-
|
6
|
-
# Add additional assets to the asset load path
|
7
|
-
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
-
|
9
|
-
# Precompile additional assets.
|
10
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
-
Rails.application.config.assets.precompile += %w( mtdevise/jumbotron-narrow.css mtdevise/non-responsive.css)
|
2
|
+
Rails.application.config.assets.precompile += %w( mtdevise/jumbotron-narrow.css mtdevise/non-responsive.css)
|
@@ -1,279 +1,279 @@
|
|
1
1
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
2
|
# Many of these configuration options can be set straight in your model.
|
3
3
|
Devise.setup do |config|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
4
|
+
config.parent_controller = 'Mtdevise::ApplicationController'
|
5
|
+
# The secret key used by Devise. Devise uses this key to generate
|
6
|
+
# random tokens. Changing this key will render invalid all existing
|
7
|
+
# confirmation, reset password and unlock tokens in the database.
|
8
|
+
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
|
9
|
+
# by default. You can change it below and use your own secret key.
|
10
|
+
# config.secret_key = '1debbc3132f8c5fbb648b82bf07c1116f4ea159c7e43434d7703ffd115b9a39f07a0f86db2a8f1bf3145ac2bacfa6a0cf4ca2ba1f2cb2185d74aeec882c10554'
|
11
|
+
|
12
|
+
# ==> Mailer Configuration
|
13
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
14
|
+
# note that it will be overwritten if you use your own mailer class
|
15
|
+
# with default "from" parameter.
|
16
|
+
config.mailer_sender = ENV["PHC_MTDEVISE_SENDER"]
|
17
|
+
|
18
|
+
# Configure the class responsible to send e-mails.
|
19
|
+
# config.mailer = 'Devise::Mailer'
|
20
|
+
|
21
|
+
# ==> ORM configuration
|
22
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
23
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
24
|
+
# available as additional gems.
|
25
|
+
require 'devise/orm/active_record'
|
26
|
+
|
27
|
+
# ==> Configuration for any authentication mechanism
|
28
|
+
# Configure which keys are used when authenticating a user. The default is
|
29
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
30
|
+
# authenticating a user, both parameters are required. Remember that those
|
31
|
+
# parameters are used only when authenticating and not when retrieving from
|
32
|
+
# session. If you need permissions, you should implement that in a before filter.
|
33
|
+
# You can also supply a hash where the value is a boolean determining whether
|
34
|
+
# or not authentication should be aborted when the value is not present.
|
35
|
+
# config.authentication_keys = [:email]
|
36
|
+
|
37
|
+
# Configure parameters from the request object used for authentication. Each entry
|
38
|
+
# given should be a request method and it will automatically be passed to the
|
39
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
40
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
41
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
42
|
+
# config.request_keys = []
|
43
|
+
|
44
|
+
# Configure which authentication keys should be case-insensitive.
|
45
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
46
|
+
# to authenticate or find a user. Default is :email.
|
47
|
+
config.case_insensitive_keys = [:email]
|
48
|
+
|
49
|
+
# Configure which authentication keys should have whitespace stripped.
|
50
|
+
# These keys will have whitespace before and after removed upon creating or
|
51
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
52
|
+
config.strip_whitespace_keys = [:email]
|
53
|
+
|
54
|
+
# Tell if authentication through request.params is enabled. True by default.
|
55
|
+
# It can be set to an array that will enable params authentication only for the
|
56
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
57
|
+
# enable it only for database (email + password) authentication.
|
58
|
+
# config.params_authenticatable = true
|
59
|
+
|
60
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
61
|
+
# It can be set to an array that will enable http authentication only for the
|
62
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
63
|
+
# enable it only for database authentication. The supported strategies are:
|
64
|
+
# :database = Support basic authentication with authentication key + password
|
65
|
+
# config.http_authenticatable = false
|
66
|
+
|
67
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
68
|
+
# config.http_authenticatable_on_xhr = true
|
69
|
+
|
70
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
71
|
+
# config.http_authentication_realm = 'Application'
|
72
|
+
|
73
|
+
# It will change confirmation, password recovery and other workflows
|
74
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
75
|
+
# Does not affect registerable.
|
76
|
+
# config.paranoid = true
|
77
|
+
|
78
|
+
# By default Devise will store the user in session. You can skip storage for
|
79
|
+
# particular strategies by setting this option.
|
80
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
81
|
+
# may want to disable generating routes to Devise's sessions controller by
|
82
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
83
|
+
config.skip_session_storage = [:http_auth]
|
84
|
+
|
85
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
86
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
87
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
88
|
+
# from the server. You can disable this option at your own risk.
|
89
|
+
# config.clean_up_csrf_token_on_authentication = true
|
90
|
+
|
91
|
+
# ==> Configuration for :database_authenticatable
|
92
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
93
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
94
|
+
#
|
95
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
96
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
97
|
+
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
98
|
+
# encryptor), the cost increases exponentially with the number of stretches (e.g.
|
99
|
+
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
100
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
101
|
+
|
102
|
+
# Setup a pepper to generate the encrypted password.
|
103
|
+
# config.pepper = '1355e6a23471bdd2eef16bb9f5673ca97d6745ec4951a0a058ee113451e788008e3f89b03a905d85e4224b94d60f1bb57b210a579e8d7116e414a475cdce19bc'
|
104
|
+
|
105
|
+
# ==> Configuration for :confirmable
|
106
|
+
# A period that the user is allowed to access the website even without
|
107
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
108
|
+
# able to access the website for two days without confirming their account,
|
109
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
110
|
+
# the user cannot access the website without confirming their account.
|
111
|
+
# config.allow_unconfirmed_access_for = 2.days
|
112
|
+
|
113
|
+
# A period that the user is allowed to confirm their account before their
|
114
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
115
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
116
|
+
# their account can't be confirmed with the token any more.
|
117
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
118
|
+
# before confirming their account.
|
119
|
+
# config.confirm_within = 3.days
|
120
|
+
|
121
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
122
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
123
|
+
# db field (see migrations). Until confirmed, new email is stored in
|
124
|
+
# unconfirmed_email column, and copied to email column on successful confirmation.
|
125
|
+
config.reconfirmable = true
|
126
|
+
|
127
|
+
# Defines which key will be used when confirming an account
|
128
|
+
# config.confirmation_keys = [:email]
|
129
|
+
|
130
|
+
# ==> Configuration for :rememberable
|
131
|
+
# The time the user will be remembered without asking for credentials again.
|
132
|
+
# config.remember_for = 2.weeks
|
133
|
+
|
134
|
+
# Invalidates all the remember me tokens when the user signs out.
|
135
|
+
config.expire_all_remember_me_on_sign_out = true
|
136
|
+
|
137
|
+
# If true, extends the user's remember period when remembered via cookie.
|
138
|
+
# config.extend_remember_period = false
|
139
|
+
|
140
|
+
# Options to be passed to the created cookie. For instance, you can set
|
141
|
+
# secure: true in order to force SSL only cookies.
|
142
|
+
# config.rememberable_options = {}
|
143
|
+
|
144
|
+
# ==> Configuration for :validatable
|
145
|
+
# Range for password length.
|
146
|
+
config.password_length = 8..72
|
147
|
+
|
148
|
+
# Email regex used to validate email formats. It simply asserts that
|
149
|
+
# one (and only one) @ exists in the given string. This is mainly
|
150
|
+
# to give user feedback and not to assert the e-mail validity.
|
151
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
152
|
+
|
153
|
+
# ==> Configuration for :timeoutable
|
154
|
+
# The time you want to timeout the user session without activity. After this
|
155
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
156
|
+
# config.timeout_in = 30.minutes
|
157
|
+
|
158
|
+
# If true, expires auth token on session timeout.
|
159
|
+
# config.expire_auth_token_on_timeout = false
|
160
|
+
|
161
|
+
# ==> Configuration for :lockable
|
162
|
+
# Defines which strategy will be used to lock an account.
|
163
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
164
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
165
|
+
# config.lock_strategy = :failed_attempts
|
166
|
+
|
167
|
+
# Defines which key will be used when locking and unlocking an account
|
168
|
+
# config.unlock_keys = [:email]
|
169
|
+
|
170
|
+
# Defines which strategy will be used to unlock an account.
|
171
|
+
# :email = Sends an unlock link to the user email
|
172
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
173
|
+
# :both = Enables both strategies
|
174
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
175
|
+
# config.unlock_strategy = :both
|
176
|
+
|
177
|
+
# Number of authentication tries before locking an account if lock_strategy
|
178
|
+
# is failed attempts.
|
179
|
+
# config.maximum_attempts = 20
|
180
|
+
|
181
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
182
|
+
# config.unlock_in = 1.hour
|
183
|
+
|
184
|
+
# Warn on the last attempt before the account is locked.
|
185
|
+
# config.last_attempt_warning = true
|
186
|
+
|
187
|
+
# ==> Configuration for :recoverable
|
188
|
+
#
|
189
|
+
# Defines which key will be used when recovering the password for an account
|
190
|
+
# config.reset_password_keys = [:email]
|
191
|
+
|
192
|
+
# Time interval you can reset your password with a reset password key.
|
193
|
+
# Don't put a too small interval or your users won't have the time to
|
194
|
+
# change their passwords.
|
195
|
+
config.reset_password_within = 6.hours
|
196
|
+
|
197
|
+
# When set to false, does not sign a user in automatically after their password is
|
198
|
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
199
|
+
# config.sign_in_after_reset_password = true
|
200
|
+
|
201
|
+
# ==> Configuration for :encryptable
|
202
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
203
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
204
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
205
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
206
|
+
# REST_AUTH_SITE_KEY to pepper).
|
207
|
+
#
|
208
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
209
|
+
# config.encryptor = :sha512
|
210
|
+
|
211
|
+
# ==> Scopes configuration
|
212
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
213
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
214
|
+
# are using only default views.
|
215
|
+
# config.scoped_views = false
|
216
|
+
|
217
|
+
# Configure the default scope given to Warden. By default it's the first
|
218
|
+
# devise role declared in your routes (usually :user).
|
219
|
+
# config.default_scope = :user
|
220
|
+
|
221
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
222
|
+
# only the current scope. By default, Devise signs out all scopes.
|
223
|
+
# config.sign_out_all_scopes = true
|
224
|
+
|
225
|
+
# ==> Navigation configuration
|
226
|
+
# Lists the formats that should be treated as navigational. Formats like
|
227
|
+
# :html, should redirect to the sign in page when the user does not have
|
228
|
+
# access, but formats like :xml or :json, should return 401.
|
229
|
+
#
|
230
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
231
|
+
# should add them to the navigational formats lists.
|
232
|
+
#
|
233
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
234
|
+
# config.navigational_formats = ['*/*', :html]
|
235
|
+
|
236
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
237
|
+
# config.sign_out_via = :delete
|
238
|
+
|
239
|
+
# ==> OmniAuth
|
240
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
241
|
+
# up on your models and hooks.
|
242
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
243
|
+
|
244
|
+
# ==> Warden configuration
|
245
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
246
|
+
# change the failure app, you can configure them inside the config.warden block.
|
247
|
+
#
|
248
|
+
# config.warden do |manager|
|
249
|
+
# manager.intercept_401 = false
|
250
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
251
|
+
# end
|
252
|
+
config.warden do |manager|
|
253
|
+
manager.default_strategies(scope: :user).unshift :subdomain_login
|
254
|
+
end
|
255
|
+
|
256
|
+
# ==> Mountable engine configurations
|
257
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
258
|
+
# is mountable, there are some extra configurations to be taken into account.
|
259
|
+
# The following options are available, assuming the engine is mounted as:
|
260
|
+
#
|
261
|
+
# mount MyEngine, at: '/my_engine'
|
262
|
+
#
|
263
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
264
|
+
config.router_name = :mtdevise
|
265
|
+
#
|
266
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
267
|
+
# so you need to do it manually. For the users scope, it would be:
|
268
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
269
|
+
|
270
|
+
# Devise Custom Layouts
|
271
|
+
Rails.application.config.to_prepare do
|
272
|
+
Devise::SessionsController.layout proc{ |controller| action_name == 'new' ? "layouts/mtdevise/signin" : "layouts/mtdevise/accounts" }
|
273
|
+
Devise::RegistrationsController.layout proc{ |controller| user_signed_in? ? "layouts/mtdevise/useredit" : "layouts/mtdevise/accounts" }
|
274
|
+
Devise::ConfirmationsController.layout "layouts/mtdevise/accounts"
|
275
|
+
Devise::UnlocksController.layout "layouts/mtdevise/accounts"
|
276
|
+
Devise::PasswordsController.layout "layouts/mtdevise/accounts"
|
277
|
+
end
|
278
278
|
|
279
279
|
end
|