Browse files

Disable self registration link

  • Loading branch information...
1 parent 477f29f commit 3cdf9ecdc1941a46c86b61e724efaa711896d7ab @nackd nackd committed Dec 29, 2010
Showing with 30 additions and 0 deletions.
  1. +1 −0 init.rb
  2. +29 −0 lib/cas/setting_patch.rb
View
1 init.rb
@@ -7,6 +7,7 @@
require 'redmine'
require 'cas/account_controller_patch'
require 'cas/application_controller_patch'
+require 'cas/setting_patch'
require 'cas/user_patch'
Redmine::Plugin.register :redmine_cas do
View
29 lib/cas/setting_patch.rb
@@ -0,0 +1,29 @@
+require 'dispatcher'
+
+# Patches Redmine's Setting dinamically. Disables self registration link.
+module CAS
+ module SettingPatch
+ def self.included(base) # :nodoc:
+ base.extend(ClassMethods)
+
+ base.class_eval do
+ unloadable # Mark as unloadable so it is reloaded in development
+
+ class << self
+ alias_method_chain :self_registration?, :cas
+ end
+ end
+ end
+
+ module ClassMethods
+ def self_registration_with_cas?
+ CAS::CONFIG['enabled'] ? false : self_registration_without_cas?
+ end
+ end
+ end
+end
+
+Dispatcher.to_prepare do
+ require_dependency 'setting'
+ Setting.send(:include, CAS::SettingPatch)
+end

0 comments on commit 3cdf9ec

Please sign in to comment.