示例#1
0
 /**
  * Remove the specified Account .
  *
  * @param $account
  *
  */
 public function postDelete($account)
 {
     if (empty($account->id)) {
         $account = CloudAccount::where('user_id', Auth::id())->find($account);
     }
     $deployment = Deployment::where('user_id', Auth::id())->where('cloudAccountId', $account->id)->get();
     if (!$deployment->isEmpty()) {
         return Redirect::to('account')->with('error', 'Deployment is linked with this account and hence cannot be deleted');
     }
     CloudAccount::where('id', $account->id)->where('user_id', Auth::id())->delete();
     $id = $account->id;
     $account->delete();
     // Was the comment post deleted?
     $account = CloudAccount::where('user_id', Auth::id())->find($id);
     if (empty($account)) {
         // TODO needs to delete all of that user's content
         return Redirect::to('account')->with('success', 'Removed Account Successfully');
     } else {
         // There was a problem deleting the user
         return Redirect::to('account/' . $account->id . '/edit')->with('error', 'Error while deleting');
     }
 }
示例#2
0
 public function getDownloadKey($id)
 {
     $this->check(true);
     $instanceID = Input::get('instanceID');
     $deployment = Deployment::where('user_id', Auth::id())->find($id);
     $account = CloudAccount::where('user_id', Auth::id())->findOrFail($deployment->cloudAccountId);
     $arr = $this->executeAction('downloadKey', $account, $deployment, $instanceID);
     if ($arr['status'] == 'OK') {
         $key = StringHelper::decrypt($arr['key'], md5(Auth::user()->username));
         header('Content-Description: File Transfer');
         header('Content-Type: ' . 'application/x-pem-file');
         header('Content-Disposition: attachment; filename=' . $arr['keyName'] . '.pem');
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . strlen($key));
         print $key;
     }
 }
示例#3
0
 public static function findAndDecrypt($id)
 {
     $account = CloudAccount::where('user_id', Auth::id())->findOrFail($id);
     $account->credentials = StringHelper::decrypt($account->credentials, md5(Auth::user()->username));
     return $account;
 }
示例#4
0
 /**
  * Show a list of all the blog posts formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $accounts = CloudAccount::select(array('cloudAccounts.id', 'cloudAccounts.name', 'cloudAccounts.cloudProvider', 'users.username', 'users.email', 'cloudAccounts.created_at'))->join('users', 'users.id', '=', 'cloudAccounts.user_id');
     return Datatables::of($accounts)->remove_column('id')->make();
 }