Esempio n. 1
0
 public function store()
 {
     $validation = new SeatApiKeyValidator();
     if ($validation->passes()) {
         // Check if we already know about this keyID
         $key_data = SeatKey::withTrashed()->where('keyID', Input::get('keyID'))->first();
         if (!$key_data) {
             $key_data = new SeatKey();
         }
         $key_data->keyID = Input::get('keyID');
         $key_data->vCode = Input::get('vCode');
         $key_data->isOk = 1;
         $key_data->lastError = null;
         $key_data->deleted_at = null;
         $key_data->user_id = 1;
         $key_data->save();
         return Response::json(array('error' => false, 'status' => 'Key has been added/updated.'), 200);
     } else {
         // if validation fails, respond
         return Response::json(array('error' => true, 'message' => $validation->errors->toArray()), 412);
     }
 }
Esempio n. 2
0
    return View::make('ajax-form')->with('keyID', Input::get('keyID'))->with('vCode', Input::get('vCode'))->with('key_info', $key_info)->with('status_info', $status_info)->with('application_reference', $application_reference);
});
Route::post('/apply/process', function () {
    if (!Session::has(Input::get('reference'))) {
        return View::make('error')->withErrors(array('error' => 'Your application was not found'));
    }
    $key_data_array = Session::get(Input::get('reference'));
    $keyID = $key_data_array['keyID'];
    $vCode = $key_data_array['vCode'];
    // We have the application and everything *seems* ok.
    // Store the key in the database
    $key_data = SeatKey::withTrashed()->where('keyID', $keyID)->first();
    if (!$key_data) {
        $key_data = new SeatKey();
    }
    $key_data->keyID = $keyID;
    $key_data->vCode = $vCode;
    $key_data->isOk = 1;
    $key_data->lastError = null;
    $key_data->deleted_at = null;
    $key_data->user_id = 1;
    // TODO: Fix this when the proper user management occurs
    $key_data->save();
    $data = array('application_content' => Input::all());
    Mail::send('emails.newapplication', $data, function ($message) {
        foreach (Config::get('recruitment.notifications') as $name => $email) {
            $message->to($email, $name)->subject('New Application Received');
        }
    });
    return View::make('success');
});
Esempio n. 3
0
 public function getAdd($keyID, $vCode)
 {
     $validation = new APIKeyValidator(array('keyID' => $keyID, 'vCode' => $vCode));
     if ($validation->passes()) {
         // Check if we have this key in the db, even those that are soft deleted
         $key_data = SeatKey::withTrashed()->where('keyID', $keyID)->first();
         if (!$key_data) {
             $key_data = new SeatKey();
         }
         $key_data->keyID = $keyID;
         $key_data->vCode = $vCode;
         $key_data->isOk = 1;
         $key_data->lastError = null;
         $key_data->deleted_at = null;
         $key_data->user_id = \Auth::User()->id;
         $key_data->save();
         // Queue a job to update this API **now**
         $access = EveApi\BaseApi::determineAccess($keyID);
         if (!isset($access['type'])) {
             return Redirect::action('ApiKeyController@getAll')->with('warning', 'Key was successfully added, but a update job was not submitted.');
         }
         // Based in the key type, push a update job
         switch ($access['type']) {
             case 'Character':
                 // Do a fresh AccountStatus lookup
                 Account\AccountStatus::update($keyID, $vCode);
                 $jobID = \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Character', $key_data->keyID, $key_data->vCode, 'Character', 'Eve');
                 break;
             case 'Corporation':
                 $jobID = \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Corporation', $key_data->keyID, $key_data->vCode, 'Corporation', 'Eve');
                 break;
             default:
                 $jobID = 'Unknown';
                 break;
         }
         return Redirect::action('ApiKeyController@getAll')->with('success', 'Key was successfully added and job ' . $jobID . ' was queued to update it.');
     } else {
         return Redirect::action('ApiKeyController@getNewKey')->withErrors($validation->errors);
     }
 }