From ae568b6182544b84067aa099eec494da477d083f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 12:09:11 -0800 Subject: Refactor the identity provider installation in to a common helper method (change_provider) with an initialization callback. --- modules/gallery/libraries/IdentityProvider.php | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'modules/gallery') diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php index bcb3056a..f7be33e3 100644 --- a/modules/gallery/libraries/IdentityProvider.php +++ b/modules/gallery/libraries/IdentityProvider.php @@ -57,6 +57,35 @@ class IdentityProvider_Core { Kohana_Config::instance()->clear("identity"); } + /** + * Return a commen confirmation message + */ + static function confirmation_message() { + return t("Are you sure you want to change your Identity Provider? " . + "Continuing will delete all existing users."); + } + + static function change_provider($new_provider) { + $current_provider = module::get_var("gallery", "identity_provider"); + if (!empty($current_provider)) { + module::uninstall($current_provider); + } + + IdentityProvider::reset(); + $provider = new IdentityProvider($new_provider); + + module::set_var("gallery", "identity_provider", $new_provider); + + if (method_exists("{$new_provider}_installer", "initialize")) { + call_user_func("{$new_provider}_installer::initialize"); + } + + module::event("identity_provider_changed", $current_provider, $new_provider); + + auth::login($provider->admin_user()); + Session::instance()->regenerate(); + } + /** * Loads the configured driver and validates it. * -- cgit v1.2.3