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; }
/** * 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'); } }
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; } }