Permalink
Browse files

account: disallow password change

  • Loading branch information...
1 parent 70a2b0d commit 477f29f9e7bc7b7bc66a69b288309ba2afb49a19 @nackd nackd committed Dec 29, 2010
Showing with 31 additions and 2 deletions.
  1. +1 −0 init.rb
  2. +1 −1 lib/cas/account_controller_patch.rb
  3. +1 −1 lib/cas/application_controller_patch.rb
  4. +28 −0 lib/cas/user_patch.rb
View
@@ -7,6 +7,7 @@
require 'redmine'
require 'cas/account_controller_patch'
require 'cas/application_controller_patch'
+require 'cas/user_patch'
Redmine::Plugin.register :redmine_cas do
name 'CAS Web Authentication'
@@ -1,7 +1,6 @@
require 'casclient'
require 'casclient/frameworks/rails/filter'
require 'dispatcher'
-require_dependency 'account_controller'
# Patches Redmine's AccountController dinamically. Manages login and logout
# through CAS.
@@ -52,5 +51,6 @@ def register_with_cas
end
Dispatcher.to_prepare do
+ require_dependency 'account_controller'
AccountController.send(:include, CAS::AccountControllerPatch)
end
@@ -1,7 +1,6 @@
require 'casclient'
require 'casclient/frameworks/rails/filter'
require 'dispatcher'
-require_dependency 'application_controller'
# Patches Redmine's ApplicationController dinamically. Prepends a CAS gatewaying
# filter.
@@ -50,5 +49,6 @@ def set_user_id
end
Dispatcher.to_prepare do
+ require_dependency 'application_controller'
ApplicationController.send(:include, CAS::ApplicationControllerPatch)
end
View
@@ -0,0 +1,28 @@
+require 'dispatcher'
+
+# Patches Redmine's User dinamically. Disallows password change.
+module CAS
+ module UserPatch
+ def self.included(base) # :nodoc:
+ base.send(:include, InstanceMethods)
+
+ base.class_eval do
+ unloadable # Mark as unloadable so it is reloaded in development
+
+ alias_method_chain :change_password_allowed?, :cas
+ end
+ end
+
+ module InstanceMethods
+ def change_password_allowed_with_cas?
+ CAS::CONFIG['enabled'] ? false : change_password_allowed_without_cas
+ end
+ end
+ end
+end
+
+Dispatcher.to_prepare do
+ require_dependency 'principal'
+ require_dependency 'user'
+ User.send(:include, CAS::UserPatch)
+end

0 comments on commit 477f29f

Please sign in to comment.