Example #1
0
         				
         				Part 2: So users can manage their applications we will also store a reference
         				in couchdb so we can generate a list of applications for them to browser.
         				The CouchDB record will hold the key in redis to get the auth tokens. This will probably
         				not be under heavy usage, so the slower couchdb is fine. Basically CouchDB will get the metadata
         				of the application
         			*/
         $application = new Application($form->inputId);
         $application->setApplicationOwner($session->user);
         $application->setDescription($form->inputName);
         $application->setDomain($form->inputDomain);
         $application->setApplicationType($form->inputType);
         $application->setDefaultPermissions($form->inputRead | $form->inputWrite | $form->inputDelete);
         $certificate = $application->generate_certificate();
         if ($certificate) {
             $metadata = $application->generate_metadata();
             $redis = Renegade::database(RenegadeConstants::kDatabaseRedis, RenegadeConstants::kDatabaseCertificates);
             $mongodb = Renegade::database(RenegadeConstants::kDatabaseMongoDB, RenegadeConstants::kDatabaseApplications);
             $mongodb->insert($metadata);
             $redis->set($certificate['key'], json_encode($certificate['value']));
         }
         header('Location:/applications');
     } else {
         foreach ($form->validators as $validator) {
             if ($validator->isValid == false) {
                 echo $validator->message . "\n";
             }
         }
     }
 } else {
     header('Location: /');