diff --git a/appinfo/application.php b/appinfo/application.php index d55c568..83b2563 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -14,7 +14,7 @@ namespace OCA\Registration\AppInfo; use \OCP\AppFramework\App; -use \OCA\Registration\Controller\RegistrationController; +use \OCA\Registration\Controller\RegisterController; use \OCA\Registration\Wrapper; @@ -28,8 +28,8 @@ class Application extends App { /** * Controllers */ - $container->registerService('RegistrationController', function($c) { - return new RegistrationController( + $container->registerService('RegisterController', function($c) { + return new RegisterController( $c->query('AppName'), $c->query('Request') ); @@ -51,6 +51,10 @@ class Application extends App { return $c->query('ServerContainer')->getL10N($c->query('AppName')); }); + $container->registerService('URLGenerator', function($c) { + return $c->getServer()->getURLGenerator(); + }); + $container->registerService('PendingRegist', function($c) { return new PendingRegist($c->query('ServerContainer')->getDb()); }); diff --git a/controller/registrationcontroller.php b/controller/registercontroller.php similarity index 87% rename from controller/registrationcontroller.php rename to controller/registercontroller.php index d3b21a3..f461b71 100644 --- a/controller/registrationcontroller.php +++ b/controller/registercontroller.php @@ -17,16 +17,18 @@ use \OCP\AppFramework\Http\TemplateResponse; use \OCP\AppFramework\Controller; use \OCA\Registration\Wrapper; -class RegistrationController extends Controller { +class RegisterController extends Controller { private $mail; private $l10n; private $db; + private $urlgenerator; - public function __construct($appName, IRequest $request, Mail $mail, $l10n, $db){ + public function __construct($appName, IRequest $request, Mail $mail, $l10n, $db, $urlgenerator){ $this->mail = $mail; $this->l10n = $l10n; $this->db = $db; + $this->urlgenerator = $urlgenerator; parent::__construct($appName, $request); } @@ -35,7 +37,7 @@ class RegistrationController extends Controller { * @NoCSRFRequired * @PublicPage */ - public function displayRegisterPage($errormsg, $entered) { + public function askEmail($errormsg, $entered) { $params = array( 'errormsg' => $errormsg ? $errormsg : $this->request->getParam('errormsg'), 'entered' => $entered ? $entered : $this->request->getParam('entered') @@ -63,8 +65,7 @@ class RegistrationController extends Controller { // FEATURE: allow only from specific email domain $token = $this->db->savePendingRegistration($email); - $link = OC_Helper::linkToRoute('core_registration_register_form', - array('token' => $token)); + $link = $this->urlgenerator->linkToRoute('registration.verify.token', array('token' => $token)); $link = OC_Helper::makeURLAbsolute($link); $from = OCP\Util::getDefaultEmailAddress('register'); $tmpl = new OC_Template('core/registration', 'email'); @@ -78,3 +79,4 @@ class RegistrationController extends Controller { } $this->displayRegisterPage('', true); } +}