Example #1
0
 */
 if ($form->isValid) {
     // The data for an application is sored in MongoDB, the rest is in Redis
     /* this is a 2 part process
     				Part 1: We need to create the auth info for the application
     				because this will be being used for access, and potentially MANY calls
     				it has to be fast, so we will store the auth token in Redis.
     				
     				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) {