mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-03-14 12:29:44 +01:00
commit
dd2e77d479
22
app/Bus/Events/System/SystemCheckedForUpdatesEvent.php
Normal file
22
app/Bus/Events/System/SystemCheckedForUpdatesEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
/**
|
||||
* This is the system checked for updates event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class SystemCheckedForUpdatesEvent implements SystemEventInterface
|
||||
{
|
||||
//
|
||||
}
|
24
app/Bus/Events/System/SystemEventInterface.php
Normal file
24
app/Bus/Events/System/SystemEventInterface.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\EventInterface;
|
||||
|
||||
/**
|
||||
* This is the system event interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface SystemEventInterface extends EventInterface
|
||||
{
|
||||
//
|
||||
}
|
22
app/Bus/Events/System/SystemWasInstalledEvent.php
Normal file
22
app/Bus/Events/System/SystemWasInstalledEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
/**
|
||||
* This is the system was installed event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class SystemWasInstalledEvent implements SystemEventInterface
|
||||
{
|
||||
//
|
||||
}
|
22
app/Bus/Events/System/SystemWasResetEvent.php
Normal file
22
app/Bus/Events/System/SystemWasResetEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
/**
|
||||
* This is the system was reset event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class SystemWasResetEvent implements SystemEventInterface
|
||||
{
|
||||
//
|
||||
}
|
22
app/Bus/Events/System/SystemWasUpdatedEvent.php
Normal file
22
app/Bus/Events/System/SystemWasUpdatedEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
/**
|
||||
* This is the system was updated event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class SystemWasUpdatedEvent implements SystemEventInterface
|
||||
{
|
||||
//
|
||||
}
|
41
app/Bus/Events/User/UserDisabledTwoAuthEvent.php
Normal file
41
app/Bus/Events/User/UserDisabledTwoAuthEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user disabled two auth event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserDisabledTwoAuthEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that disabled two auth.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user disabled two auth event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserEnabledTwoAuthEvent.php
Normal file
41
app/Bus/Events/User/UserEnabledTwoAuthEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user enabled two auth event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserEnabledTwoAuthEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that enabled two auth.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user enabled two auth event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserFailedTwoAuthEvent.php
Normal file
41
app/Bus/Events/User/UserFailedTwoAuthEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user failed two auth event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserFailedTwoAuthEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that failed two auth.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user failed two auth event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserLoggedInEvent.php
Normal file
41
app/Bus/Events/User/UserLoggedInEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user logged in event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserLoggedInEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that logged in.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user logged in event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserLoggedOutEvent.php
Normal file
41
app/Bus/Events/User/UserLoggedOutEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user logged out event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserLoggedOutEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that logged out.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user logged out event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserPassedTwoAuthEvent.php
Normal file
41
app/Bus/Events/User/UserPassedTwoAuthEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user passed two auth event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserPassedTwoAuthEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that passed two auth.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user passed two auth event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
41
app/Bus/Events/User/UserRegeneratedApiTokenEvent.php
Normal file
41
app/Bus/Events/User/UserRegeneratedApiTokenEvent.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user regenerated api token event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserRegeneratedApiTokenEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that regenerated their api token.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user regenerated api token event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
@ -87,6 +87,39 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasVerifiedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemCheckedForUpdatesEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserDisabledTwoAuthEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserEnabledTwoAuthEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserFailedTwoAuthEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserLoggedInEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserLoggedOutEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserPassedTwoAuthEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserRegeneratedApiTokenEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasAddedEvent' => [
|
||||
//
|
||||
],
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserFailedTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserLoggedInEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserLoggedOutEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserPassedTwoAuthEvent;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -62,6 +66,8 @@ class AuthController extends Controller
|
||||
// We probably want to add support for "Remember me" here.
|
||||
Auth::attempt($loginData);
|
||||
|
||||
event(new UserLoggedInEvent(Auth::user()));
|
||||
|
||||
return Redirect::intended('dashboard');
|
||||
}
|
||||
|
||||
@ -99,8 +105,14 @@ class AuthController extends Controller
|
||||
$valid = Google2FA::verifyKey(Auth::user()->google_2fa_secret, $code);
|
||||
|
||||
if ($valid) {
|
||||
event(new UserPassedTwoAuthEvent(Auth::user()));
|
||||
|
||||
event(new UserLoggedInEvent(Auth::user()));
|
||||
|
||||
return Redirect::intended('dashboard');
|
||||
} else {
|
||||
event(new UserFailedTwoAuthEvent(Auth::user()));
|
||||
|
||||
// Failed login, log back out.
|
||||
Auth::logout();
|
||||
|
||||
@ -118,6 +130,8 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
event(new UserLoggedOutEvent(Auth::user()));
|
||||
|
||||
Auth::logout();
|
||||
|
||||
return Redirect::to('/');
|
||||
|
@ -12,6 +12,9 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserDisabledTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserEnabledTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserRegeneratedApiTokenEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
@ -46,8 +49,10 @@ class UserController extends Controller
|
||||
|
||||
// Let's enable/disable auth
|
||||
if ($enable2FA && !Auth::user()->hasTwoFactor) {
|
||||
event(new UserEnabledTwoAuthEvent(Auth::user()));
|
||||
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
|
||||
} elseif (!$enable2FA) {
|
||||
event(new UserDisabledTwoAuthEvent(Auth::user()));
|
||||
$userData['google_2fa_secret'] = '';
|
||||
}
|
||||
|
||||
@ -76,6 +81,8 @@ class UserController extends Controller
|
||||
$user->api_key = User::generateApiKey();
|
||||
$user->save();
|
||||
|
||||
event(new UserRegeneratedApiTokenEvent($user));
|
||||
|
||||
return Redirect::route('dashboard.user');
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,11 @@ interface System
|
||||
* @return array
|
||||
*/
|
||||
public function getStatus();
|
||||
|
||||
/**
|
||||
* Get the cachet version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion();
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ class System implements SystemContract
|
||||
public function getStatus()
|
||||
{
|
||||
$enabledScope = Component::enabled();
|
||||
$totalComponents = Component::enabled()->count();
|
||||
$majorOutages = Component::enabled()->status(4)->count();
|
||||
$totalComponents = $enabledScope->count();
|
||||
$majorOutages = $enabledScope->status(4)->count();
|
||||
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
|
||||
|
||||
// Default data
|
||||
@ -47,7 +47,7 @@ class System implements SystemContract
|
||||
'system_message' => trans_choice('cachet.service.major', $totalComponents),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
} elseif (Component::enabled()->notStatus(1)->count() === 0) {
|
||||
} elseif ($enabledScope->notStatus(1)->count() === 0) {
|
||||
// If all our components are ok, do we have any non-fixed incidents?
|
||||
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get()->filter(function ($incident) {
|
||||
return $incident->status > 0;
|
||||
@ -61,10 +61,20 @@ class System implements SystemContract
|
||||
'favicon' => 'favicon',
|
||||
];
|
||||
}
|
||||
} elseif (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
|
||||
} elseif ($enabledScope->whereIn('status', [2, 3])->count() > 0) {
|
||||
$status['favicon'] = 'favicon-medium-alert';
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cachet version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return CACHET_VERSION;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\GitHub;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemCheckedForUpdatesEvent;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Releases as ReleasesContract;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
@ -82,6 +83,8 @@ class Releases implements ReleasesContract
|
||||
$headers['OAUTH-TOKEN'] = $this->token;
|
||||
}
|
||||
|
||||
event(new SystemCheckedForUpdatesEvent());
|
||||
|
||||
return json_decode((new Client())->get($this->url, [
|
||||
'headers' => $headers,
|
||||
])->getBody(), true);
|
||||
|
@ -11,6 +11,9 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Subscribers;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent;
|
||||
use CachetHQ\Cachet\Settings\Cache;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
@ -63,19 +66,67 @@ class CommandSubscriber
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen('command.installing', __CLASS__.'@fire', 5);
|
||||
$events->listen('command.updating', __CLASS__.'@fire', 5);
|
||||
$events->listen('command.resetting', __CLASS__.'@fire', 5);
|
||||
$events->listen('command.installing', __CLASS__.'@fireInstallingCommand', 5);
|
||||
$events->listen('command.updating', __CLASS__.'@fireUpdatingCommand', 5);
|
||||
$events->listen('command.resetting', __CLASS__.'@fireResettingCommand', 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the settings cache, and backup the databases.
|
||||
* Fire the installing command.
|
||||
*
|
||||
* @param \Illuminate\Console\Command $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire(Command $command)
|
||||
public function fireInstallingCommand(Command $command)
|
||||
{
|
||||
$this->handleMainCommand($command);
|
||||
|
||||
event(new SystemWasInstalledEvent());
|
||||
|
||||
$command->success('System was installed!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the updating command.
|
||||
*
|
||||
* @param \Illuminate\Console\Command $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fireUpdatingCommand(Command $command)
|
||||
{
|
||||
$this->handleMainCommand($command);
|
||||
|
||||
event(new SystemWasUpdatedEvent());
|
||||
|
||||
$command->success('System was updated!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the resetting command.
|
||||
*
|
||||
* @param \Illuminate\Console\Command $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fireResettingCommand(Command $command)
|
||||
{
|
||||
$this->handleMainCommand($command);
|
||||
|
||||
event(new SystemWasResetEvent());
|
||||
|
||||
$command->success('System was reset!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the main bulk of the command, clear the settings and backup the database.
|
||||
*
|
||||
* @param \Illuminate\Console\Command $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleMainCommand(Command $command)
|
||||
{
|
||||
$command->line('Clearing settings cache...');
|
||||
|
||||
|
31
tests/Bus/Events/System/AbstractSystemEventTestCase.php
Normal file
31
tests/Bus/Events/System/AbstractSystemEventTestCase.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\System;
|
||||
|
||||
use AltThree\TestBench\EventTrait;
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemEventInterface;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the abstract system event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractSystemEventTestCase extends AbstractTestCase
|
||||
{
|
||||
use EventTrait;
|
||||
|
||||
protected function getEventInterfaces()
|
||||
{
|
||||
return [SystemEventInterface::class];
|
||||
}
|
||||
}
|
35
tests/Bus/Events/System/SystemCheckedForUpdatesEventTest.php
Normal file
35
tests/Bus/Events/System/SystemCheckedForUpdatesEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\System;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemCheckedForUpdatesEvent;
|
||||
|
||||
/**
|
||||
* This is the system checked for updates event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class SystemCheckedForUpdatesEventTest extends AbstractSystemEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new SystemCheckedForUpdatesEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
35
tests/Bus/Events/System/SystemWasInstalledEventTest.php
Normal file
35
tests/Bus/Events/System/SystemWasInstalledEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\System;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent;
|
||||
|
||||
/**
|
||||
* This is the system was installed event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class SystemWasInstalledEventTest extends AbstractSystemEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new SystemWasInstalledEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
35
tests/Bus/Events/System/SystemWasResetEventTest.php
Normal file
35
tests/Bus/Events/System/SystemWasResetEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\System;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent;
|
||||
|
||||
/**
|
||||
* This is the system was reset event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class SystemWasResetEventTest extends AbstractSystemEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new SystemWasResetEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
35
tests/Bus/Events/System/SystemWasUpdatedEventTest.php
Normal file
35
tests/Bus/Events/System/SystemWasUpdatedEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\System;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent;
|
||||
|
||||
/**
|
||||
* This is the system was updated event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class SystemWasUpdatedEventTest extends AbstractSystemEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new SystemWasUpdatedEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserDisabledTwoAuthEventTest.php
Normal file
36
tests/Bus/Events/User/UserDisabledTwoAuthEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserDisabledTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user disabled two auth event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserDisabledTwoAuthEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserDisabledTwoAuthEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserEnabledTwoAuthEventTest.php
Normal file
36
tests/Bus/Events/User/UserEnabledTwoAuthEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserEnabledTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user enabled two auth event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserEnabledTwoAuthEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserEnabledTwoAuthEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserFailedTwoAuthEventTest.php
Normal file
36
tests/Bus/Events/User/UserFailedTwoAuthEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserFailedTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user failed two auth event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserFailedTwoAuthEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserFailedTwoAuthEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserLoggedInEventTest.php
Normal file
36
tests/Bus/Events/User/UserLoggedInEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserLoggedInEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user logged in event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserLoggedInEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserLoggedInEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserLoggedOutEventTest.php
Normal file
36
tests/Bus/Events/User/UserLoggedOutEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserLoggedOutEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user logged out event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserLoggedOutEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserLoggedOutEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserPassedTwoAuthEventTest.php
Normal file
36
tests/Bus/Events/User/UserPassedTwoAuthEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserPassedTwoAuthEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user passed two auth event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserPassedTwoAuthEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserPassedTwoAuthEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
36
tests/Bus/Events/User/UserRegeneratedApiTokenEventTest.php
Normal file
36
tests/Bus/Events/User/UserRegeneratedApiTokenEventTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserRegeneratedApiTokenEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user regenerated api token event test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserRegeneratedApiTokenEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new UserRegeneratedApiTokenEvent($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user