carnival 0.0.45 → 0.0.47

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.
Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/carnival/omniauth_callbacks_controller.rb +28 -20
  3. data/app/datatable/carnival/generic_datatable.rb +4 -4
  4. data/app/helpers/carnival/base_admin_helper.rb +1 -1
  5. data/app/models/carnival/admin_user.rb +11 -3
  6. data/app/models/carnival/admin_user_notification.rb +5 -0
  7. data/app/models/carnival/model_helper.rb +2 -2
  8. data/app/models/carnival/notification.rb +5 -0
  9. data/app/views/admin_users/shared/_links.html.haml +1 -1
  10. data/config/initializers/devise.rb +13 -0
  11. data/lib/carnival/config.rb +4 -1
  12. data/lib/carnival/routes.rb +5 -1
  13. data/lib/carnival/version.rb +1 -1
  14. data/lib/generators/carnival/templates/carnival_initializer.rb +7 -0
  15. data/test/dummy/config/initializers/carnival_initializer.rb +273 -0
  16. data/test/dummy/db/development.sqlite3 +0 -0
  17. data/test/dummy/log/development.log +7681 -0
  18. data/test/dummy/tmp/cache/assets/development/sprockets/07e2c1c7f749a9d38b1649aec1d98730 +0 -0
  19. data/test/dummy/tmp/cache/assets/development/sprockets/565023fdd3960225e817ec043b2d9474 +0 -0
  20. data/test/dummy/tmp/cache/assets/development/sprockets/5d4c2ae09c50a0b53500e334aa699c8a +0 -0
  21. data/test/dummy/tmp/cache/assets/development/sprockets/5dff23c7dbd41b1db43fea8c8d933e94 +0 -0
  22. data/test/dummy/tmp/cache/assets/development/sprockets/6ad4d1acfed3cffae46c712b7c08af08 +0 -0
  23. data/test/dummy/tmp/cache/assets/development/sprockets/b632a78e3341b622d2afbcb5312f9da0 +0 -0
  24. data/test/dummy/tmp/cache/assets/development/sprockets/c3f8745dd91cb1b9a0c076a692369c4a +0 -0
  25. data/test/dummy/tmp/cache/assets/development/sprockets/d16461dfcae4b782f721ebd81e4f8740 +0 -0
  26. data/test/dummy/tmp/cache/assets/development/sprockets/d2ea65cc83e604dee36a5316b567e3e2 +0 -0
  27. data/test/dummy/tmp/cache/assets/development/sprockets/d554039ac665d1a72c5af06725134a59 +0 -0
  28. data/test/dummy/tmp/pids/server.pid +1 -1
  29. metadata +78 -58
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffc2753f9b67ad49fe598591d927d8fb3e27aa04
4
+ data.tar.gz: 1cece4769f4d618a0c28c963f2adc7e64d48716b
5
+ SHA512:
6
+ metadata.gz: a21205e689c40f1d1666b659055c468991cbed5185964afe81026bdca38e4707009121702a14b3f94f04af0fa58556a59ec6d051da185f691cd73f7722be661b
7
+ data.tar.gz: e3752804cb8e39d30d5efa26e78976ed4675ca48eb9d4efab0104f1e166a7846a9b9bbe2cdfa286077ceef5c98c59e9cb79c5afd68cbba03166215a27166eae0
@@ -1,26 +1,34 @@
1
- class Carnival::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
- def facebook
3
- # You need to implement the method below in your model (e.g. app/models/user.rb)
4
- @user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])
1
+ module Carnival
2
+ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
+ def facebook
4
+ # You need to implement the method below in your model (e.g. app/models/user.rb)
5
+ @user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])
5
6
 
6
- if @user.persisted?
7
- sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
8
- set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
9
- else
10
- session["devise.facebook_data"] = request.env["omniauth.auth"]
11
- redirect_to new_user_registration_url
7
+ if @user.nil?
8
+ flash.notice = I18n.t("user_not_found")
9
+ redirect_to new_admin_user_session_path
10
+ elsif @user.persisted?
11
+ sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
12
+ set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
13
+ else
14
+ session["devise.facebook_data"] = request.env["omniauth.auth"]
15
+ redirect_to new_user_registration_url
16
+ end
12
17
  end
13
- end
14
18
 
15
- def google_oauth2
16
- user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])
17
- if user.persisted?
18
- flash.notice = "Signed in Through Google!"
19
- sign_in_and_redirect user
20
- else
21
- session["devise.user_attributes"] = user.attributes
22
- flash.notice = "You are almost Done! Please provide a password to finish setting up your account"
23
- redirect_to new_user_registration_url
19
+ def google_oauth2
20
+ @user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])
21
+ if @user.nil?
22
+ flash.notice = I18n.t("user_not_found")
23
+ redirect_to new_admin_user_session_path
24
+ elsif @user.persisted?
25
+ flash.notice = "Signed in Through Google!"
26
+ sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
27
+ else
28
+ session["devise.user_attributes"] = @user.attributes
29
+ flash.notice = "You are almost Done! Please provide a password to finish setting up your account"
30
+ redirect_to new_user_registration_url
31
+ end
24
32
  end
25
33
  end
26
34
  end
@@ -88,20 +88,20 @@ module Carnival
88
88
 
89
89
  if render_type == RENDER_CSV
90
90
  @presenter.fields_for_action(:csv).each do |key, field|
91
- data_item[i.to_label] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => true}
91
+ data_item[i.to_s] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => true}
92
92
  i = i + 1
93
93
  end
94
94
  elsif render_type == RENDER_PDF
95
95
  @presenter.fields_for_action(:pdf).each do |key, field|
96
- data_item[i.to_label] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => true}
96
+ data_item[i.to_s] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => true}
97
97
  i = i + 1
98
98
  end
99
99
  else render_type == RENDER_TABLE
100
100
  @presenter.fields_for_action(:index).each do |key, field|
101
- data_item[i.to_label] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => false}
101
+ data_item[i.to_s] = ac.render_to_string :formats => [:html] , :partial => '/carnival/shared/list_cel', :locals => {:presenter => @presenter,:field=> key, :record=> record, :only_render_fields => false}
102
102
  i = i + 1
103
103
  end
104
- data_item[i.to_label] = ac.render_to_string :formats => [:html], :partial => '/carnival/shared/item_buttons', :locals => {:record=>record, :presenter => @presenter}
104
+ data_item[i.to_s] = ac.render_to_string :formats => [:html], :partial => '/carnival/shared/item_buttons', :locals => {:record=>record, :presenter => @presenter}
105
105
  i = i + 1
106
106
  end
107
107
  data << data_item
@@ -59,7 +59,7 @@ module Carnival
59
59
  current_type = field_type(presenter,field)
60
60
  if current_type == :relation
61
61
  if show_only_value
62
- record.send(field.to_s).to_s
62
+ record.send(field.to_s).to_label
63
63
  else
64
64
  return link_to presenter.relation_label(field.to_sym, record), presenter.relation_path(field.to_sym, record)
65
65
  end
@@ -1,10 +1,19 @@
1
1
  module Carnival
2
2
 
3
3
  class AdminUser < ActiveRecord::Base
4
+ include Carnival::ModelHelper
5
+ devise_flags = *Carnival::Config.devise_config
6
+ devise_flags << :recoverable
7
+ devise_flags << :rememberable
4
8
 
5
- devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
9
+ if devise_flags.include?(:omniauthable)
10
+ devise :database_authenticatable, *devise_flags.uniq, omniauth_providers: Carnival::Config.omniauth_providers
11
+ else
12
+ devise :database_authenticatable, *devise_flags.uniq
13
+ end
6
14
 
7
15
  has_many :admin_user_notifications
16
+ has_many :notifications, through: :admin_user_notifications
8
17
 
9
18
  def unread_notifications
10
19
  self.admin_user_notifications.where(:read => false).to_a
@@ -23,7 +32,7 @@ module Carnival
23
32
  user.provider = auth.provider
24
33
  user.uid = auth.uid
25
34
  user
26
- else
35
+ elsif Carnival::Config.devise_config.include?(:registerable)
27
36
  where(auth.slice(:provider, :uid)).first_or_create do |user|
28
37
  user.provider = auth.provider
29
38
  user.uid = auth.uid
@@ -35,5 +44,4 @@ module Carnival
35
44
  end
36
45
  end
37
46
  end
38
-
39
47
  end
@@ -1,6 +1,8 @@
1
1
  module Carnival
2
2
  class AdminUserNotification < ActiveRecord::Base
3
3
  include ActionView::Helpers::UrlHelper
4
+ include Carnival::ModelHelper
5
+
4
6
  belongs_to :admin_user
5
7
  belongs_to :notification
6
8
 
@@ -16,5 +18,8 @@ module Carnival
16
18
  self.notification.link
17
19
  end
18
20
 
21
+ def to_label
22
+ self.notification.title
23
+ end
19
24
  end
20
25
  end
@@ -13,9 +13,9 @@ module Carnival::ModelHelper
13
13
  select = []
14
14
  select << ['', ''] if params[:add_empty_option]
15
15
  if params[:reverse]
16
- select.concat all.collect{|c|[c.to_s, c.id]}
16
+ select.concat all.collect{|c|[c.to_label, c.id]}
17
17
  else
18
- select.concat all.collect{|c|[c.id, c.to_s]}
18
+ select.concat all.collect{|c|[c.id, c.to_label]}
19
19
  end
20
20
  select
21
21
  end
@@ -1,5 +1,10 @@
1
1
  module Carnival
2
2
  class Notification < ActiveRecord::Base
3
+ include Carnival::ModelHelper
3
4
  has_many :admin_user_notifications
5
+
6
+ def to_label
7
+ self.title
8
+ end
4
9
  end
5
10
  end
@@ -11,4 +11,4 @@
11
11
  .oauth
12
12
  - resource_class.omniauth_providers.each do |provider|
13
13
  %div{class: provider}
14
- = link_to "Login com #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
14
+ = link_to "Login com #{provider.to_s.titleize}", admin_user_omniauth_authorize_path(provider: provider)
@@ -251,4 +251,17 @@ Devise.setup do |config|
251
251
  # When using omniauth, Devise cannot automatically set Omniauth path,
252
252
  # so you need to do it manually. For the users scope, it would be:
253
253
  # config.omniauth_path_prefix = '/my_engine/users/auth'
254
+
255
+ if Carnival::Config.omniauth.present?
256
+ puts "=" * 100
257
+ puts Carnival::Config.omniauth.inspect
258
+ if Carnival::Config.omniauth[:facebook].present?
259
+ require "omniauth-facebook"
260
+ config.omniauth :facebook, Carnival::Config.omniauth[:facebook][0], Carnival::Config.omniauth[:facebook][1]
261
+ end
262
+ if Carnival::Config.omniauth[:google_oauth2].present?
263
+ require "omniauth-google-oauth2"
264
+ config.omniauth :google_oauth2, Carnival::Config.omniauth[:google_oauth2][0], Carnival::Config.omniauth[:google_oauth2][1]
265
+ end
266
+ end
254
267
  end
@@ -1,8 +1,11 @@
1
1
  module Carnival
2
2
 
3
3
  class Config
4
- mattr_accessor :menu
4
+ mattr_accessor :menu, :devise_config, :omniauth, :omniauth_providers
5
5
  @@menu
6
+ @@devise_config
7
+ @@omniauth
8
+ @@omniauth_providers
6
9
  end
7
10
 
8
11
  end
@@ -5,7 +5,11 @@ module ActionDispatch::Routing
5
5
  get "admin_user_notification/read/:id" => 'carnival/admin_user_notifications#read', as: :carnival_read_admin_user_notification
6
6
  resources :admin_user_notifications, controller: "carnival/admin_user_notifications", :as => :carnival_admin_user_notifications
7
7
  resources :admin_users, controller: "carnival/admin_users", :as => :carnival_admin_users
8
- devise_for :admin_users, :class_name => "Carnival::AdminUser", :path => "sessions", :controllers => { :sessions => "carnival/sessions" }
8
+ if Carnival::Config.devise_config.include?(:omniauthable) and Carnival::Config.omniauth.present?
9
+ devise_for :admin_users, :class_name => "Carnival::AdminUser", :path => "sessions", :controllers => { :sessions => "carnival/sessions", :omniauth_callbacks => "carnival/omniauth_callbacks" }
10
+ else
11
+ devise_for :admin_users, :class_name => "Carnival::AdminUser", :path => "sessions", :controllers => { :sessions => "carnival/sessions"}
12
+ end
9
13
  root to: "carnival/admin_users#index", :as => :admin_root
10
14
  end
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module Carnival
2
- VERSION = "0.0.45"
2
+ VERSION = "0.0.47"
3
3
  end
@@ -39,3 +39,10 @@ Carnival::Config.menu = {
39
39
  ]
40
40
  }
41
41
  }
42
+ Carnival::Config.devise_config = :registerable, :recoverable, :rememberable, :trackable, :validatable,
43
+ :omniauthable
44
+
45
+ Carnival::Config.omniauth_providers = [:facebook, :google_oauth2]
46
+
47
+ Carnival::Config.omniauth = {facebook: ["324810390938005", "3c16625e74189a3708cc586dc050a6b2"],
48
+ google_oauth2: ['431077382019-mumumjahr5cn6cooubtskc6ohael7923.apps.googleusercontent.com', 'ilH4B-KXN3tqG6qF9gGN1F_J']}
@@ -39,3 +39,276 @@ Carnival::Config.menu = {
39
39
  ]
40
40
  }
41
41
  }
42
+
43
+ Carnival::Config.devise_config = :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable
44
+
45
+ Carnival::Config.omniauth_providers = [:facebook, :google_oauth2]
46
+
47
+ Carnival::Config.omniauth = {facebook: ["324810390938005", "3c16625e74189a3708cc586dc050a6b2"],
48
+ google_oauth2: ['431077382019-mumumjahr5cn6cooubtskc6ohael7923.apps.googleusercontent.com', 'ilH4B-KXN3tqG6qF9gGN1F_J']}
49
+
50
+ # Use this hook to configure devise mailer, warden hooks and so forth.
51
+ # Many of these configuration options can be set straight in your model.
52
+ Devise.setup do |config|
53
+ # The secret key used by Devise. Devise uses this key to generate
54
+ # random tokens. Changing this key will render invalid all existing
55
+ # confirmation, reset password and unlock tokens in the database.
56
+ config.secret_key = '34c7fc396b3c8671d7009261e6a6bc30a47d4f048b1d646b4fc868dc6666b58fe4e9087bf2462054b9677660de1592f88e2aefacd75bb47c7e2d1c770291620b'
57
+
58
+ # ==> Mailer Configuration
59
+ # Configure the e-mail address which will be shown in Devise::Mailer,
60
+ # note that it will be overwritten if you use your own mailer class
61
+ # with default "from" parameter.
62
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
63
+
64
+ # Configure the class responsible to send e-mails.
65
+ # config.mailer = 'Devise::Mailer'
66
+
67
+ # ==> ORM configuration
68
+ # Load and configure the ORM. Supports :active_record (default) and
69
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
70
+ # available as additional gems.
71
+ require 'devise/orm/active_record'
72
+
73
+ # ==> Configuration for any authentication mechanism
74
+ # Configure which keys are used when authenticating a user. The default is
75
+ # just :email. You can configure it to use [:username, :subdomain], so for
76
+ # authenticating a user, both parameters are required. Remember that those
77
+ # parameters are used only when authenticating and not when retrieving from
78
+ # session. If you need permissions, you should implement that in a before filter.
79
+ # You can also supply a hash where the value is a boolean determining whether
80
+ # or not authentication should be aborted when the value is not present.
81
+ # config.authentication_keys = [ :email ]
82
+
83
+ # Configure parameters from the request object used for authentication. Each entry
84
+ # given should be a request method and it will automatically be passed to the
85
+ # find_for_authentication method and considered in your model lookup. For instance,
86
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
87
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
88
+ # config.request_keys = []
89
+
90
+ # Configure which authentication keys should be case-insensitive.
91
+ # These keys will be downcased upon creating or modifying a user and when used
92
+ # to authenticate or find a user. Default is :email.
93
+ config.case_insensitive_keys = [ :email ]
94
+
95
+ # Configure which authentication keys should have whitespace stripped.
96
+ # These keys will have whitespace before and after removed upon creating or
97
+ # modifying a user and when used to authenticate or find a user. Default is :email.
98
+ config.strip_whitespace_keys = [ :email ]
99
+
100
+ # Tell if authentication through request.params is enabled. True by default.
101
+ # It can be set to an array that will enable params authentication only for the
102
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
103
+ # enable it only for database (email + password) authentication.
104
+ # config.params_authenticatable = true
105
+
106
+ # Tell if authentication through HTTP Auth is enabled. False by default.
107
+ # It can be set to an array that will enable http authentication only for the
108
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
109
+ # enable it only for database authentication. The supported strategies are:
110
+ # :database = Support basic authentication with authentication key + password
111
+ # config.http_authenticatable = false
112
+
113
+ # If http headers should be returned for AJAX requests. True by default.
114
+ # config.http_authenticatable_on_xhr = true
115
+
116
+ # The realm used in Http Basic Authentication. 'Application' by default.
117
+ # config.http_authentication_realm = 'Application'
118
+
119
+ # It will change confirmation, password recovery and other workflows
120
+ # to behave the same regardless if the e-mail provided was right or wrong.
121
+ # Does not affect registerable.
122
+ # config.paranoid = true
123
+
124
+ # By default Devise will store the user in session. You can skip storage for
125
+ # particular strategies by setting this option.
126
+ # Notice that if you are skipping storage for all authentication paths, you
127
+ # may want to disable generating routes to Devise's sessions controller by
128
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
129
+ config.skip_session_storage = [:http_auth]
130
+
131
+ # By default, Devise cleans up the CSRF token on authentication to
132
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
133
+ # requests for sign in and sign up, you need to get a new CSRF token
134
+ # from the server. You can disable this option at your own risk.
135
+ # config.clean_up_csrf_token_on_authentication = true
136
+
137
+ # ==> Configuration for :database_authenticatable
138
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
139
+ # using other encryptors, it sets how many times you want the password re-encrypted.
140
+ #
141
+ # Limiting the stretches to just one in testing will increase the performance of
142
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
143
+ # a value less than 10 in other environments.
144
+ config.stretches = Rails.env.test? ? 1 : 10
145
+
146
+ # Setup a pepper to generate the encrypted password.
147
+ # config.pepper = 'f87de298ab9a4d0239a5409f8a780e8369a501e96a2629d62fc4f63ad0b139071896351c3e5200bedca5932c3f580a9c846a6f9d2e363af79329483f0ea975d7'
148
+
149
+ # ==> Configuration for :confirmable
150
+ # A period that the user is allowed to access the website even without
151
+ # confirming his account. For instance, if set to 2.days, the user will be
152
+ # able to access the website for two days without confirming his account,
153
+ # access will be blocked just in the third day. Default is 0.days, meaning
154
+ # the user cannot access the website without confirming his account.
155
+ # config.allow_unconfirmed_access_for = 2.days
156
+
157
+ # A period that the user is allowed to confirm their account before their
158
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
159
+ # their account within 3 days after the mail was sent, but on the fourth day
160
+ # their account can't be confirmed with the token any more.
161
+ # Default is nil, meaning there is no restriction on how long a user can take
162
+ # before confirming their account.
163
+ # config.confirm_within = 3.days
164
+
165
+ # If true, requires any email changes to be confirmed (exactly the same way as
166
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
167
+ # db field (see migrations). Until confirmed new email is stored in
168
+ # unconfirmed email column, and copied to email column on successful confirmation.
169
+ config.reconfirmable = true
170
+
171
+ # Defines which key will be used when confirming an account
172
+ # config.confirmation_keys = [ :email ]
173
+
174
+ # ==> Configuration for :rememberable
175
+ # The time the user will be remembered without asking for credentials again.
176
+ # config.remember_for = 2.weeks
177
+
178
+ # If true, extends the user's remember period when remembered via cookie.
179
+ # config.extend_remember_period = false
180
+
181
+ # Options to be passed to the created cookie. For instance, you can set
182
+ # :secure => true in order to force SSL only cookies.
183
+ # config.rememberable_options = {}
184
+
185
+ # ==> Configuration for :validatable
186
+ # Range for password length. Default is 8..128.
187
+ config.password_length = 8..128
188
+
189
+ # Email regex used to validate email formats. It simply asserts that
190
+ # one (and only one) @ exists in the given string. This is mainly
191
+ # to give user feedback and not to assert the e-mail validity.
192
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
193
+
194
+ # ==> Configuration for :timeoutable
195
+ # The time you want to timeout the user session without activity. After this
196
+ # time the user will be asked for credentials again. Default is 30 minutes.
197
+ # config.timeout_in = 30.minutes
198
+
199
+ # If true, expires auth token on session timeout.
200
+ # config.expire_auth_token_on_timeout = false
201
+
202
+ # ==> Configuration for :lockable
203
+ # Defines which strategy will be used to lock an account.
204
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
205
+ # :none = No lock strategy. You should handle locking by yourself.
206
+ # config.lock_strategy = :failed_attempts
207
+
208
+ # Defines which key will be used when locking and unlocking an account
209
+ # config.unlock_keys = [ :email ]
210
+
211
+ # Defines which strategy will be used to unlock an account.
212
+ # :email = Sends an unlock link to the user email
213
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
214
+ # :both = Enables both strategies
215
+ # :none = No unlock strategy. You should handle unlocking by yourself.
216
+ # config.unlock_strategy = :both
217
+
218
+ # Number of authentication tries before locking an account if lock_strategy
219
+ # is failed attempts.
220
+ # config.maximum_attempts = 20
221
+
222
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
223
+ # config.unlock_in = 1.hour
224
+
225
+ # Warn on the last attempt before the account is locked.
226
+ # config.last_attempt_warning = false
227
+
228
+ # ==> Configuration for :recoverable
229
+ #
230
+ # Defines which key will be used when recovering the password for an account
231
+ # config.reset_password_keys = [ :email ]
232
+
233
+ # Time interval you can reset your password with a reset password key.
234
+ # Don't put a too small interval or your users won't have the time to
235
+ # change their passwords.
236
+ config.reset_password_within = 6.hours
237
+
238
+ # ==> Configuration for :encryptable
239
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
240
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
241
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
242
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
243
+ # REST_AUTH_SITE_KEY to pepper).
244
+ #
245
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
246
+ # config.encryptor = :sha512
247
+
248
+ # ==> Scopes configuration
249
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
250
+ # "users/sessions/new". It's turned off by default because it's slower if you
251
+ # are using only default views.
252
+ config.scoped_views = true
253
+
254
+ # Configure the default scope given to Warden. By default it's the first
255
+ # devise role declared in your routes (usually :user).
256
+ # config.default_scope = :user
257
+
258
+ # Set this configuration to false if you want /users/sign_out to sign out
259
+ # only the current scope. By default, Devise signs out all scopes.
260
+ # config.sign_out_all_scopes = true
261
+
262
+ # ==> Navigation configuration
263
+ # Lists the formats that should be treated as navigational. Formats like
264
+ # :html, should redirect to the sign in page when the user does not have
265
+ # access, but formats like :xml or :json, should return 401.
266
+ #
267
+ # If you have any extra navigational formats, like :iphone or :mobile, you
268
+ # should add them to the navigational formats lists.
269
+ #
270
+ # The "*/*" below is required to match Internet Explorer requests.
271
+ # config.navigational_formats = ['*/*', :html]
272
+
273
+ # The default HTTP method used to sign out a resource. Default is :delete.
274
+ config.sign_out_via = :delete
275
+
276
+ # ==> OmniAuth
277
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
278
+ # up on your models and hooks.
279
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
280
+
281
+ # ==> Warden configuration
282
+ # If you want to use other strategies, that are not supported by Devise, or
283
+ # change the failure app, you can configure them inside the config.warden block.
284
+ #
285
+ # config.warden do |manager|
286
+ # manager.intercept_401 = false
287
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
288
+ # end
289
+
290
+ # ==> Mountable engine configurations
291
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
292
+ # is mountable, there are some extra configurations to be taken into account.
293
+ # The following options are available, assuming the engine is mounted as:
294
+ #
295
+ # mount MyEngine, at: '/my_engine'
296
+ #
297
+ # The router that invoked `devise_for`, in the example above, would be:
298
+ # config.router_name = :my_engine
299
+ #
300
+ # When using omniauth, Devise cannot automatically set Omniauth path,
301
+ # so you need to do it manually. For the users scope, it would be:
302
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
303
+
304
+ if Carnival::Config.devise_config.include?(:omniauthable) and Carnival::Config.omniauth.present?
305
+ if Carnival::Config.omniauth[:facebook].present?
306
+ require "omniauth-facebook"
307
+ config.omniauth :facebook, Carnival::Config.omniauth[:facebook][0], Carnival::Config.omniauth[:facebook][1]
308
+ end
309
+ if Carnival::Config.omniauth[:google_oauth2].present?
310
+ require "omniauth-google-oauth2"
311
+ config.omniauth :google_oauth2, Carnival::Config.omniauth[:google_oauth2][0], Carnival::Config.omniauth[:google_oauth2][1]
312
+ end
313
+ end
314
+ end