Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --cc app/controllers/application_controller.rb
- index 9d4f99a,9d4f99a,9d4f99a,9d4f99a..7313d36
- --- a/app/controllers/application_controller.rb
- +++ b/app/controllers/application_controller.rb
- @@@@@ -3,7 -3,7 -3,7 -3,7 +3,6 @@@@@ class ApplicationController < ActionCon
- before_filter :initialize_query_filter
- before_filter :authenticate_user!
- ---- before_filter :handle_password_change
- private
- @@@@@ -23,30 -23,30 -23,30 -23,30 +22,4 @@@@@
- end
- end
- ---- # lookup if an password change needed
- ---- def handle_password_change
- ---- if !devise_controller? and !request.format.nil? && request.format.html?
- ---- Devise.mappings.keys.flatten.any? do |scope|
- ---- if signed_in?(scope) and warden.session(scope)[:password_expired]
- ---- session["#{scope}_return_to"] = request.path if request.get?
- ---- redirect_for_password_change scope
- ---- return
- ---- end
- ---- end
- ---- end
- ---- end
- ----
- ---- # redirect for password update with alert message
- ---- def redirect_for_password_change(scope)
- ---- redirect_to change_password_required_path_for(scope), :alert => I18n.t('change_required', {:scope => 'devise.password_expired'})
- ---- end
- ----
- ---- # path for change password
- ---- def change_password_required_path_for(resource_or_scope = nil)
- ---- scope = Devise::Mapping.find_scope!(resource_or_scope)
- ---- change_path = "#{scope}_password_expired_path"
- ---- send(change_path)
- ---- end
- ----
- ----
- end
- diff --cc app/controllers/password_expired_controller.rb
- index 3eb1091,3eb1091,3eb1091,3eb1091..0000000
- --- a/app/controllers/password_expired_controller.rb
- +++ b/app/controllers/password_expired_controller.rb
- diff --cc app/models/password_expirable.rb
- index a8a2ecb,a8a2ecb,a8a2ecb,a8a2ecb..0000000
- --- a/app/models/password_expirable.rb
- +++ b/app/models/password_expirable.rb
- diff --cc app/models/user.rb
- index 7d66b32,7d66b32,7d66b32,7d66b32..bc6f635
- --- a/app/models/user.rb
- +++ b/app/models/user.rb
- @@@@@ -1,6 -1,6 -1,6 -1,6 +1,6 @@@@@
- class User
- include Mongoid::Document
- ---- devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable, :password_expirable
- ++++ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable
- ## Database authenticatable
- field :email, :type => String, :null => false, :default => ""
- @@@@@ -20,15 -20,15 -20,15 -20,15 +20,9 @@@@@
- field :current_sign_in_ip, :type => String
- field :last_sign_in_ip, :type => String
- ---- ## Password expirable
- ---- field :password_changed_at, :type => Time
- ----
- ## Encryptable
- # field :password_salt, :type => String
- validates_uniqueness_of :email, :case_sensitive => false
- attr_accessible :email, :password, :password_confirmation, :remember_me
- ----
- ---- validates :password, format: /^(?=.*\d)(?=.*[a-zA-Z]).{7,}$/
- ----
- end
- diff --cc app/views/password_expired/show.html.erb
- index 2873988,2873988,2873988,2873988..0000000
- --- a/app/views/password_expired/show.html.erb
- +++ b/app/views/password_expired/show.html.erb
- diff --cc config/initializers/devise.rb
- index c65b653,c65b653,c65b653,c65b653..a2bee5a
- --- a/config/initializers/devise.rb
- +++ b/config/initializers/devise.rb
- @@@@@ -121,7 -121,7 -121,7 -121,7 +121,7 @@@@@ Devise.setup do |config
- # ==> Configuration for :validatable
- # Range for password length. Default is 6..128.
- ---- config.password_length = 7..128
- ++++ # config.password_length = 6..128
- # Email regex used to validate email formats. It simply asserts that
- # an one (and only one) @ exists in the given string. This is mainly
- @@@@@ -221,25 -221,25 -221,25 -221,25 +221,3 @@@@@
- # manager.default_strategies(:scope => :user).unshift :some_external_strategy
- # end
- end
- ----
- ----Warden::Manager.after_authentication do |record, warden, options|
- ---- if record.respond_to?(:need_change_password?)
- ---- warden.session(options[:scope])[:password_expired] = record.need_change_password?
- ---- end
- ----end
- ----
- ----module ActionDispatch::Routing
- ---- class Mapper
- ----
- ---- protected
- ----
- ---- # route for handle expired passwords
- ---- def devise_password_expired(mapping, controllers)
- ---- resource :password_expired, :only => [:show, :update], :path => mapping.path_names[:password_expired], :controller => controllers[:password_expired]
- ---- end
- ----
- ---- end
- ----end
- ----
- ----Devise.add_module :password_expirable, :model => 'password_expirable', :controller => :password_expirable, :route => :password_expired
- ----
Add Comment
Please, Sign In to add comment