/** * Execute the console command. * * @return mixed */ public function fire() { // Get the API key in question from the command // line arg $keyID = $this->argument('keyID'); $this->info('Searching for key: ' . $keyID); // Find the API key in the datbase $key = \SeatKey::where('keyID', $keyID)->first(); // If we found the key, move on to asking the user // if they really want to delete the key. if (count($key) == 1) { if ($this->confirm('Are you sure you want to delete this key? [yes|no] ', true)) { // Delete the API key from thet SeAT database $key = \SeatKey::where('keyID', $keyID)->delete(); // Notify the user that they key is gone. $this->comment('Key deleted!'); // We are done and can end now return; } else { $this->info('Not doing anything'); } } else { $this->error('API Key not found.'); } }
public function showIndex() { // Prepare some summarized totals for the home view to display in the // widgets // EVE Online Server Information $server = EveServerServerStatus::find(1); // Key Information // If the user has 0 keys, we can 0 all of the values // If the user has keys, determine values only applicable to // this users keys if (!\Auth::isSuperUser()) { if (count(Session::get('valid_keys')) > 0) { $total_keys = SeatKey::whereIn('keyID', Session::get('valid_keys'))->count(); $total_characters = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->count(); $total_corporations = EveCorporationCorporationSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_corporationsheet.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->count(); $total_char_isk = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('balance'); $total_corp_isk = EveCorporationAccountBalance::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_accountbalance.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance'); $total_skillpoints = EveCharacterCharacterSheetSkills::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet_skills.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('skillpoints'); } else { $total_keys = $total_characters = $total_corporations = $total_char_isk = $total_corp_isk = $total_skillpoints = 0; } } else { // Super user gets all of the data! $total_keys = SeatKey::count(); $total_characters = EveCharacterCharacterSheet::count(); $total_corporations = EveCorporationCorporationSheet::count(); $total_char_isk = EveCharacterCharacterSheet::sum('balance'); $total_corp_isk = EveCorporationAccountBalance::where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance'); $total_skillpoints = EveCharacterCharacterSheetSkills::sum('skillpoints'); } return View::make('home')->with('server', $server)->with('total_keys', $total_keys)->with('total_characters', $total_characters)->with('total_corporations', $total_corporations)->with('total_char_isk', $total_char_isk)->with('total_corp_isk', $total_corp_isk)->with('total_skillpoints', $total_skillpoints); }
/** * Execute the console command. * * @return mixed */ public function fire() { $this->info('Finding keys that are not ok.'); // Search the database for keys that are marked as disabled foreach (\SeatKey::where('isOk', '=', 0)->get() as $key) { $this->comment('Key ' . $key->keyID . ' is not ok.'); $this->line('Characters on this key:'); // Print the characters on the affected key foreach (\EveAccountAPIKeyInfoCharacters::where('keyID', '=', $key->keyID)->get() as $character) { $this->line(' ' . $character->characterName); } } }
/** * Execute the console command. * * @return mixed */ public function fire() { // Log what we are going to do in the laravel.log file \Log::info('Started command ' . $this->name, array('src' => __CLASS__)); // Call the addToQueue helper to queue jobs for // the EVE Server, Map and General EVE info \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Server', 0, NULL, 'ServerStatus', 'Server'); \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Map', 0, NULL, 'Map', 'Eve'); \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Eve', 0, NULL, 'Eve', 'Eve'); // Log the start of the key processing \Log::info('Starting job submissions for all keys', array('src' => __CLASS__)); // Get the keys that are not disabled and process them. foreach (\SeatKey::where('isOk', '=', 1)->get() as $key) { // It is important to know the type of key we are working // with so that we may know which API calls will // apply to it. For that reason, we run the // Seat\EveApi\BaseApi\determineAccess() // function to get this. $access = EveApi\BaseApi::determineAccess($key->keyID); // If we failed to determine the access type of the // key, continue to the next key. if (!isset($access['type'])) { \Log::error('Unable to determine type for key ' . $key->keyID, array('src' => __CLASS__)); continue; } // Based on the type of key that we have determined it // to be, we will call the appropriate addToQueue // helper to schedule update jobs for switch ($access['type']) { case 'Character': // Do a fresh AccountStatus lookup Account\AccountStatus::update($key->keyID, $key->vCode); \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Character', $key->keyID, $key->vCode, 'Character', 'Eve'); break; case 'Corporation': \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Corporation', $key->keyID, $key->vCode, 'Corporation', 'Eve'); break; default: break; } } }
protected function getValidCorps($users) { $validCorps = []; $invalid = []; foreach ($users as $u) { $valid_keys = \SeatKey::where('user_id', $u->id)->lists('keyID'); if (!empty($valid_keys)) { $corporation_affiliation = \EveAccountAPIKeyInfoCharacters::whereIn('keyID', $valid_keys)->groupBy('corporationID')->lists('corporationID'); if (!empty($corporation_affiliation)) { $viable = \EveCorporationCorporationSheet::whereIn('corporationID', $corporation_affiliation)->lists('corporationName'); if (!empty($viable)) { $validCorps[] = ['corps' => $viable, 'user' => $u, 'user_groups' => \Auth::getUserGroups($u)]; } } } else { $invalid[] = $u; } } return [$validCorps, $invalid]; }
public static function Update() { // Grab all of the API keys that SeAT // is aware of $seat_keys = \SeatKey::all(); // Looping over all of the keys, we will find // the superusers and send them the // notification about this foreach ($seat_keys as $seat_key) { if ($seat_key->isOk == 0) { // We have a key that is not OK, find // some people to tell about this! foreach (\Auth::findAllUsersWithAccess('superuser') as $super_user) { // Compile the full notification $notification_type = 'API'; $notification_title = 'Disabled Key'; $notification_text = 'The SeAT backend has disabled API key ' . $seat_key->keyID . '. ' . 'The last error was: ' . $seat_key->lastError; // Send the Notification BaseNotify::sendNotification($super_user->id, $notification_type, $notification_title, $notification_text); } } } }
public static function canAccessCorp($userID, $corpID) { // Get the SeAT user based on the userID $user = \Auth::findUserById($userID); // Determine the keys that the user owns $valid_keys = \SeatKey::where('user_id', $user->id)->lists('keyID'); // Check if we have received any keys in the // previous query if (!empty($valid_keys)) { // Get a list of the corporationID's that the // user is affaliated with $corporation_affiliation = \EveAccountAPIKeyInfoCharacters::whereIn('keyID', $valid_keys)->groupBy('corporationID')->lists('corporationID'); // With the affiliations known, loop over them // matching the affaliated corporationID with // the corporationID in question foreach ($corporation_affiliation as $affiliation) { // If we have a match, return true if ($affiliation == $corpID) { return true; } } } return false; }
Session::put($application_reference, array('keyID' => Input::get('keyID'), 'vCode' => Input::get('vCode'))); // Return the view 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'); } });
public function getDeleteUser($userID) { $user = Auth::findUserById($userID); // Lets return the keys that this user owned back // to the admin user \SeatKey::where('user_id', $user->id)->update(array('user_id' => 1)); $user->forceDelete(); return Redirect::action('UserController@getAll')->with('success', 'User has been deleted'); }
/** * Execute the console command. * * @return mixed */ public function fire() { // Log what we are going to do in the laravel.log file \Log::info('Started command ' . $this->name, array('src' => __CLASS__)); // Get the keys that are not disabled and process them. foreach (\SeatKey::where('isOk', '=', 1)->get() as $key) { // It is important to know the type of key we are working // with so that we may know which API calls will // apply to it. For that reason, we run the // Seat\EveApi\BaseApi\determineAccess() // function to get this. $access = EveApi\BaseApi::determineAccess($key->keyID); // If we failed to determine the access type of the // key, continue to the next key. if (!isset($access['type'])) { //TODO: Log this key's problems and disable it continue; } // If the key is a of type 'Character', then we can // continue to submit a updater job if ($access['type'] == 'Character') { // Do a fresh AccountStatus lookup Account\AccountStatus::update($key->keyID, $key->vCode); // Once the fresh account status lookup is done, call the // addToQueue helper to queue a new job. \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Character', $key->keyID, $key->vCode, 'Character', 'Eve'); } } }
public function destroy($id) { $deleted_rows = SeatKey::where('keyID', $id)->delete(); if ($deleted_rows > 0) { return Response::json(array('error' => false, 'message' => 'Key ' . $id . ' has been deleted.'), 200); } return Response::json(array('error' => true, 'message' => 'Unknown key.'), 400); }
public function postTransferOwnership() { // Ensure that this user is a super admin if (!\Auth::isSuperUser()) { App::abort(404); } // Find the API Key and user... $key_information = SeatKey::where('keyID', Input::get('keyID'))->first(); $seat_user = User::where('id', Input::get('accountid'))->first(); // ... and check that they exist if (!$key_information || !$seat_user) { App::abort(404); } $key_information->user_id = Input::get('accountid'); $key_information->save(); return Redirect::action('ApiKeyController@getDetail', array(Input::get('keyID')))->with('success', 'API Key Ownership has been transferred'); }
public static function determineAccess($keyID) { // Locate the key in the db $key = \SeatKey::where('keyID', '=', $keyID)->where('isOk', '=', 1)->first(); if (!$key) { return array(); } // Attempt to get the type & accessMask from the database. Account\APIKeyInfo::update($keyID, $key->vCode); $key_mask_info = \EveAccountAPIKeyInfo::where('keyID', '=', $keyID)->first(); // Potential cause for #182. Comment out for now. // Account\AccountStatus::update($keyID, $key->vCode); // If we still can't determine mask information, leave everything if (!$key_mask_info) { return array(); } // Prepare a return by setting the 'type' key to the key type we have $type = $key_mask_info->type == 'Account' ? 'Character' : $key_mask_info->type; $return_access = array('type' => $type); // Loop over all the masks we have, and return those we have access to for this key foreach (\EveApiCalllist::where('type', '=', $type)->get() as $mask) { if ($key_mask_info->accessMask & $mask->accessMask) { $return_access['access'][] = array('type' => $mask->type, 'name' => $mask->name); } } // Return it all as a nice array return $return_access; }
/** * Execute the console command. * * @return mixed */ public function fire() { // Log what we are going to do in the laravel.log file \Log::info('Started command ' . $this->name, array('src' => __CLASS__)); // Get the keys that are not disabled and process them. foreach (\SeatKey::where('isOk', '=', 1)->get() as $key) { // It is important to know the type of key we are working // with so that we may know which API calls will // apply to it. For that reason, we run the // Seat\EveApi\BaseApi\determineAccess() // function to get this. $access = EveApi\BaseApi::determineAccess($key->keyID); // If we failed to determine the access type of the // key, continue to the next key. if (!isset($access['type'])) { //TODO: Log this key's problems and disable it continue; } // Only process Corporation keys if ($access['type'] == 'Corporation') { // Call the addToQueue helper to add a new update job. We // call the partial call here because some calls for // the corporation apis have bery long cache timers // and there is no use in doing all that work // for cached data. This one calls the // Assets updater \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Partial\\CorporationAssets', $key->keyID, $key->vCode, 'CorporationAssets', 'Eve'); } } }
| application. Here you may also register your custom route filters. | */ App::before(function ($request) { // Users have keys allocated to them from the `seat_keys` table. // We can check if the user is authed and if so, get the keyID's // this user is valid for. // We will also get a list of corporation ID's that the user is // affiliated to. This can be used to check the permissions then // later for specific functions such as starbases etc. // We will also check if the user has any director roles in any // of the affiliated corporations. Directors will be allowed to // assign permissions to other members of their corporation if (\Auth::check()) { // Valid API Keys $valid_keys = SeatKey::where('user_id', \Auth::User()->id)->lists('keyID'); Session::put('valid_keys', $valid_keys); // Affiliated corporationID's. if (!empty($valid_keys)) { // Get the list of corporationID's that the user is affiliated with $corporation_affiliation = EveAccountAPIKeyInfoCharacters::whereIn('keyID', $valid_keys)->groupBy('corporationID')->lists('corporationID'); Session::put('corporation_affiliations', $corporation_affiliation); // Determine which corporations the user is a director for if (!empty($corporation_affiliation)) { $is_director = EveCorporationMemberSecurityRoles::whereIn('corporationID', $corporation_affiliation)->where('roleID', '=', '1')->groupBy('corporationID')->lists('corporationID'); Session::put('is_director', $is_director); } } else { // Just to ensure that we dont have some strange errors later, lets // define a empty array in the session for corporation_affiliations Session::put('corporation_affiliations', array());