]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/commands/web/class_WebResendLinkCommand.php
User class / resending of confirm link updated:
[shipsimu.git] / inc / classes / main / commands / web / class_WebResendLinkCommand.php
index 138c44da3a865742d84bd2e6387490556aa5406a..03aa64d5c3a9e4c0f07d90ea975f171e1ec9658b 100644 (file)
@@ -64,8 +64,18 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
+        * @throws      InvalidInterfaceException       If the user class does not implement ManageableUser
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get user instance from registry
+               $userInstance = Registry::getRegistry()->getInstance('user');
+
+               // Does the user instance implement ManageableUser?
+               if (!$userInstance instanceof ManageableUser) {
+                       // Throw exception here
+                       throw new InvalidInterfaceException(array($userInstance, 'ManageableUser'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+               } // END - if
+
                // Get template instance
                $templateInstance = $responseInstance->getTemplateInstance();
 
@@ -78,6 +88,21 @@ class WebResendLinkCommand extends BaseCommand implements Commandable {
                // Assign base URL
                $templateInstance->assignConfigVariable('base_url');
 
+               // Get a RNG instance (Random Number Generator)
+               $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+
+               // Generate a pseudo-random string
+               $randomString = $rngInstance->randomString(255);
+
+               // Get a crypto instance
+               $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
+
+               // Hash and encrypt the string
+               $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString));
+
+               // Update the user class
+               $userInstance->updateDatabaseField('confirm_hash', $hashedString);
+
                // Get a mailer class
                $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance));