Skip to content

Commit

Permalink
Merge pull request #136 from eve-seat/dev
Browse files Browse the repository at this point in the history
Merge v0.9 into master
  • Loading branch information
eve-seat committed Jun 22, 2014
2 parents 503bc26 + 08d6f57 commit c5f41ca
Show file tree
Hide file tree
Showing 105 changed files with 5,736 additions and 2,038 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Release](http://img.shields.io/github/release/eve-seat/seat.svg?style=flat)](https://github.com/eve-seat/seat/releases/latest)

##### *This is very much BETA software with a ton of things not yet implemented. USE AT YOUR OWN RISK* #####
##### *SeAT is still under heavy development and is not considered 100% stable yet. USE AT YOUR OWN RISK* #####

### Introduction ###
SeAT attempts to be a EVE Online™ Corporation Management Tool written in PHP using the [Laravel][1] Framework driven by a MySQL database.
Expand Down
16 changes: 15 additions & 1 deletion app/commands/SeatAddKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Seat\EveApi;
use Seat\EveApi\BaseApi;
use Seat\EveApi\Account;
use Carthalyst\Sentry as Sentry;

class SeatAddKey extends Command {

Expand Down Expand Up @@ -44,6 +45,19 @@ public function __construct()
*/
public function fire()
{

// Keys added via the CLI will automatically be assigned to the admin
// useri as the owner. Find the 'admin' user in SeAT for later reference
try {

$admin = \Sentry::findUserByLogin('admin');

} catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {

$this->error('Admin account doesn\'t exist. Run seat:reset to create it.');
return;
}

$keyID = $this->argument('keyID');
$vCode = $this->argument('vCode');

Expand Down Expand Up @@ -87,7 +101,7 @@ public function fire()
$key_info->isOk = 1;
$key_info->lastError = null;
$key_info->deleted_at = null;
$key_info->user_id = 1; // TODO: Fix this when the proper user management occurs
$key_info->user_id = $admin->getKey();
$key_info->save();

$this->info('Successfully saved the API key to the database.');
Expand Down
127 changes: 127 additions & 0 deletions app/commands/SeatGroupSync.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

namespace Seat\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Sentry;

class SeatGroupSync extends Command {

/**
* The console command name.
*
* @var string
*/
protected $name = 'seat:groupsync';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Ensures the application has all the SeAT access groups present.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
// We will search for groups and create them if they are not present.
// Lets create an array that we can easily append to in case we need
// more groups
$groups = array(
// This group is for POS Managers to allow access to the POS
// Management View
array(
'name' => 'POS Managers',
'permissions' => array(
'pos_manager' => 1
)
),

// Wallet Manager group is to allow access to corporation wallets
// and Ledgers
array(
'name' => 'Wallet Managers',
'permissions' => array(
'wallet_manager' => 1
)
),

// Recruiters group allows access to all character sheets and keys
array(
'name' => 'Recruiters',
'permissions' => array(
'recruiter' => 1
)
),

// Asset Manager group is to allow access to Posses and Assets
array(
'name' => 'Asset Managers',
'permissions' => array(
'pos_manager' => 1,
'asset_manager' => 1
)
),

// Contract Manager group is to allow access to Posses and Assets
array(
'name' => 'Contract Managers',
'permissions' => array(
'contract_manager' => 1
)
),

// Market Manager group is to allow access to Market Orders and Assets
array(
'name' => 'Market Managers',
'permissions' => array(
'market_manager' => 1
)
)
);

// Loop over $groups and check || create as needed
foreach ($groups as $group_entry) {

try {

$group = Sentry::findGroupByName($group_entry['name']);
$this->line('[ok] Group ' . $group_entry['name'] . ' exists.');

} catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {

$this->info('[info] Group ' . $group_entry['name'] . ' was not found. Creating it.');

try {
// Create the group
$group = Sentry::createGroup(array(
'name' => $group_entry['name'],
'permissions' => $group_entry['permissions']
));
$this->line('[ok] Group ' . $group_entry['name'] . ' created.');

} catch (\Exception $e) {

$this->error('Group ' . $group_entry['name'] . ' was not created. Error: ' . $e->getMessage());

}
}
}
}
}
2 changes: 1 addition & 1 deletion app/commands/SeatQueueStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function fire()

$this->line(
'OwnerID: ' . $row->ownerID . ' | Scope: ' . $row->scope .
' | API: ' . $row->api . ' | Status: "' . $row->output .
' | API: ' . $row->api . ' | Status: "' . str_limit($row->output, 20, '...') .
'" | Created: ' . Carbon::parse($row->created_at)->diffForHumans() .
' | Last updated: ' . Carbon::parse($row->updated_at)->diffForHumans()
);
Expand Down
39 changes: 34 additions & 5 deletions app/commands/SeatReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Carthalyst\Sentry as Sentry;

class SeatReset extends Command {

Expand Down Expand Up @@ -53,16 +54,44 @@ public function fire()

$this->info('The passwords match. Resetting to the new ' . strlen($password) . ' char one.');

$admin = \User::where('username', '=', 'admin')->first();
// Attempt to find the admin user usnig Sentry helper functions.
// If the user does not exist, we create it.
try {

if (!isset($admin)) {
$admin = \Sentry::findUserByLogin('admin');

$this->error('The admin user could not be found... Have you run db:seed ?');
return;
} catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {

\Sentry::register(array(
'email' => 'admin',
'password' => $password,
), true); // Set the account to be active

$admin = \Sentry::findUserByLogin('admin');
}

// Next, we check for the existance of the admin group and create it if it
// does not exist
try {

$adminGroup = \Sentry::findGroupByName('Administrators');

} catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {

\Sentry::createGroup(array(
'name' => 'Administrators',
'permissions' => array(
'superuser' => 1,
),
));

$adminGroup = \Sentry::findGroupByName('Administrators');
}

$admin->password = \Hash::make($password);
// Set the password and group membership for the admin user.
$admin->password = $password;
$admin->save();
$admin->addGroup($adminGroup);

$this->info('Password has been changed successfully.');
}
Expand Down
3 changes: 2 additions & 1 deletion app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Indatus\Dispatcher\ServiceProvider', // Schedules
'Cartalyst\Sentry\SentryServiceProvider', // ACL

),

Expand Down Expand Up @@ -173,7 +174,7 @@
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',

'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry', // ACL
),

);
2 changes: 1 addition & 1 deletion app/config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
|
*/

'table' => 'seat_users',
'table' => 'users',

/*
|--------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit c5f41ca

Please sign in to comment.