Esempio n. 1
0
 /**
  * @param \Seat\Web\Http\Validation\CsvImport $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postCsv(CsvImport $request)
 {
     $csv = Reader::createFromFileObject($request->file('csv')->openFile());
     // Keep tabs on the amount of keys that have
     // been inserted, and how many have been
     // considered erroneous
     $updated = 0;
     $errored = 0;
     // Loop the CSV, validating the lines
     // and inserting into the database
     foreach ($csv as $k => $data) {
         // Assign the $data to readable names
         $key_id = $data[0];
         $v_code = $data[1];
         // Validate the keys. We check that we dont
         // already have this key in the database to ensure
         // that we dont mess up the ownership by accident.
         $validator = Validator::make(['key_id' => $key_id, 'v_code' => $v_code], ['key_id' => 'required|numeric|unique:eve_api_keys,key_id', 'v_code' => 'required|size:64|alpha_num']);
         // Ensure the format was ok
         if ($validator->fails()) {
             $errored++;
             continue;
         }
         // Add the API Key
         ApiKey::create(['key_id' => $key_id, 'v_code' => $v_code, 'user_id' => auth()->user()->id, 'enabled' => true]);
         $updated++;
     }
     return redirect()->back()->with('success', 'Import complete! Success: ' . $updated . '. Error: ' . $errored);
 }
Esempio n. 2
0
 /**
  * @param \Seat\Web\Validation\CsvImport $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postCsv(CsvImport $request)
 {
     // Grab the Data out of the CSV
     $file = $request->file('csv');
     $data = explode("\n", $file->openFile()->fread($file->getSize()));
     // Keep tabs on the amount of keys that have
     // been inserted, and how many have been
     // considered erroneous
     $updated = 0;
     $errored = 0;
     // Loop the CSV, validating the lines
     // and inserting into the database
     foreach ($data as $k => $key) {
         $parts = explode(",", $key);
         // Ensure we have 2 entries in the $parts array
         if (count($parts) != 2) {
             $errored++;
             continue;
         }
         // Assign the $parts to readable names
         $key_id = $parts[0];
         $v_code = $parts[1];
         $validator = Validator::make(['key_id' => $key_id, 'v_code' => $v_code], ['key_id' => 'required|numeric|unique:eve_api_keys,key_id', 'v_code' => 'required|size:64|alpha_num']);
         // Ensure the format was ok
         if ($validator->fails()) {
             $errored++;
             continue;
         }
         // Add the API Key
         ApiKey::create(['key_id' => $key_id, 'v_code' => $v_code, 'user_id' => auth()->user()->id, 'enabled' => true]);
         $updated++;
     }
     return redirect()->back()->with('success', 'Import complete! Success: ' . $updated . '. Error: ' . $errored);
 }
Esempio n. 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param \Seat\Web\Http\Validation\ApiKey $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(ApiKeyValidator $request)
 {
     // If we dont have a user_id, set it to 1
     // which is the admin user.
     if (!$request->has('user_id')) {
         $request['user_id'] = 1;
     }
     ApiKey::create($request->all());
     return response()->json(['ok']);
 }
Esempio n. 4
0
 /**
  * @param \Seat\Web\Validation\ApiKey       $request
  * @param \Seat\Eveapi\Helpers\JobContainer $job
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function addKey(ApiKey $request, JobContainer $job)
 {
     ApiKeyModel::create(['key_id' => $request->input('key_id'), 'v_code' => $request->input('v_code'), 'user_id' => auth()->user()->id, 'enabled' => true]);
     // Get a fresh instance of the API Key
     $api_key = ApiKeyModel::find($request->input('key_id'));
     $job->scope = 'Key';
     $job->api = 'Scheduler';
     $job->owner_id = $request->input('key_id');
     $job->eve_api_key = $api_key;
     // Queue the update Job
     $job_id = $this->addUniqueJob(CheckAndQueueKey::class, $job);
     return redirect()->route('api.key')->with('success', trans('web::seat.add_success', ['jobid' => $job_id]));
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param \Seat\Web\Validation\ApiKey $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(ApiKeyValidator $request)
 {
     ApiKey::create($request->all());
     return response()->json(['ok']);
 }
Esempio n. 6
0
 /**
  * @param \Seat\Web\Validation\ApiKey $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function addKey(ApiKey $request)
 {
     ApiKeyModel::create(['key_id' => $request->input('key_id'), 'v_code' => $request->input('v_code'), 'user_id' => auth()->user()->id, 'enabled' => true]);
     return redirect()->route('api.key')->with('success', trans('web::api.add_success'));
 }