Permalink
Browse files

Support ThinkUp LLC redirects

  • Loading branch information...
1 parent 0fce75c commit a398deab28ce6b8f48dd6d08985dcd8cb15fb01c @ginatrapani ginatrapani committed Dec 31, 2013
View
@@ -67,6 +67,9 @@ public function testGetValuesArray() {
$THINKUP_CFG['enable_profiler']=false;
//tests assume Mandrill is not enabled
$THINKUP_CFG['mandrill_api_key']='';
+ //tests assume ThinkUp LLC redirects are not enabled
+ $config->setValue('thinkupllc_endpoint', null);
+ $THINKUP_CFG['thinkupllc_endpoint'] = null;
$values_array = $config->getValuesArray();
$this->assertIdentical($THINKUP_CFG, $values_array);
}
@@ -167,4 +167,14 @@ public function testOfControllerWithRegistrationClosed() {
$this->assertEqual($v_mgr->getTemplateDataItem('is_registration_open'), false);
$this->assertNoPattern('/Register/', $result);
}
+
+ public function testOfThinkUpLLCRedirect() {
+ $config = Config::getInstance();
+ $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
+
+ $controller = new ForgotPasswordController(true);
+ $result = $controller->go();
+
+ $this->assertEqual($controller->redirect_destination, 'http://example.com/user/forgot.php');
+ }
}
@@ -283,4 +283,14 @@ public function testOfControllerWithRegistrationClosed() {
$this->assertEqual($v_mgr->getTemplateDataItem('is_registration_open'), false);
$this->assertNoPattern('/Register/', $result);
}
+
+ public function testOfThinkUpLLCRedirect() {
+ $config = Config::getInstance();
+ $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
+
+ $controller = new LoginController(true);
+ $result = $controller->go();
+
+ $this->assertEqual($controller->redirect_destination, 'http://example.com/user/');
+ }
}
@@ -50,4 +50,15 @@ public function testLogoutWhileLoggedIn() {
//$this->assertPattern("/You have successfully logged out/", $results);
$this->assertPattern("/Log In/", $results);
}
+
+ public function testOfThinkUpLLCRedirect() {
+ $this->simulateLogin('me@example.com');
+ $config = Config::getInstance();
+ $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
+
+ $controller = new LogoutController(true);
+ $result = $controller->go();
+
+ $this->assertEqual($controller->redirect_destination, 'http://example.com/user/logout.php');
+ }
}
@@ -581,4 +581,14 @@ public function testInviteInvalidCodeNoAppTitlePrefix() {
'<p><a href="http://thinkup.com" class="btn">Install ThinkUp on your own '.
'server.</a></p>');
}
+
+ public function testOfThinkUpLLCRedirect() {
+ $config = Config::getInstance();
+ $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
+
+ $controller = new RegisterController(true);
+ $result = $controller->go();
+
+ $this->assertEqual($controller->redirect_destination, 'http://example.com/user/');
+ }
}
@@ -56,6 +56,11 @@ public function setUp() {
if ($config->getValue('timezone')) {
date_default_timezone_set($config->getValue('timezone'));
}
+ //tests assume no redirect to ThinkUp LLC
+ if ($config->getValue('thinkupllc_endpoint') != null) {
+ $config->setValue('thinkupllc_endpoint', null);
+ }
+
$webapp_plugin_registrar = PluginRegistrarWebapp::getInstance();
$crawler_plugin_registrar = PluginRegistrarCrawler::getInstance();
$this->DEBUG = (getenv('TEST_DEBUG')!==false) ? true : false;
@@ -32,6 +32,7 @@
class ForgotPasswordController extends ThinkUpController {
public function control() {
+ $this->redirectToThinkUpLLCEndpoint('forgot.php');
$config = Config::getInstance();
$this->addToView('is_registration_open', $config->getValue('is_registration_open'));
@@ -32,6 +32,7 @@
class LoginController extends ThinkUpController {
public function control() {
+ $this->redirectToThinkUpLLCEndpoint();
$this->setPageTitle('Log in');
$this->setViewTemplate('session.login.tpl');
$this->view_mgr->addHelp('login', 'userguide/accounts/index');
@@ -32,6 +32,7 @@
*/
class LogoutController extends ThinkUpAuthController {
public function authControl() {
+ $this->redirectToThinkUpLLCEndpoint('logout.php');
Session::logout();
$controller = new InsightStreamController(true);
$controller->addSuccessMessage("You have successfully logged out.");
@@ -51,6 +51,7 @@ public function __construct($session_started=false) {
}
public function control(){
+ $this->redirectToThinkUpLLCEndpoint();
if ($this->isLoggedIn()) {
$controller = new InsightStreamController(true);
return $controller->go();
@@ -626,4 +626,20 @@ public function validateCSRFToken() {
throw new InvalidCSRFTokenException($token);
}
}
+
+ /**
+ * Redirect this controller to a ThinkUp LLC-hosted URL.
+ * @param str $page Optional filename at endpoint
+ * @return void
+ */
+ public function redirectToThinkUpLLCEndpoint($page=null) {
+ $config = Config::getInstance();
+ $thinkupllc_endpoint = $config->getValue('thinkupllc_endpoint');
+ if (isset($thinkupllc_endpoint)) {
+ $this->redirect($thinkupllc_endpoint.(isset($page)?$page:''));
+ return true;
+ } else {
+ return false;
+ }
+ }
}

0 comments on commit a398dea

Please sign in to comment.