mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
commit
536605bd97
72
app/Http/Controllers/LogoutController.php
Normal file
72
app/Http/Controllers/LogoutController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CompanyToken;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use stdClass;
|
||||
|
||||
class LogoutController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/logout",
|
||||
* operationId="getLogout",
|
||||
* tags={"logout"},
|
||||
* summary="Gets a list of logout",
|
||||
* description="Lists all logout",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
||||
* @OA\Parameter(ref="#/components/parameters/index"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Success message",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
* @param Request $request
|
||||
* @return Response|mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
CompanyToken::with('company')
|
||||
->whereRaw('BINARY `token`= ?', [$request->header('X-API-TOKEN')])
|
||||
->company
|
||||
->tokens()
|
||||
->where('is_system', true)
|
||||
->forceDelete();
|
||||
|
||||
return response()->json(['message' => 'All tokens deleted'], 200);
|
||||
}
|
||||
|
||||
}
|
@ -66,7 +66,7 @@ class SelfUpdateController extends BaseController
|
||||
throw new FilePermissionsFailure('Cannot update system because files are not writable!');
|
||||
|
||||
// Check if new version is available
|
||||
if($updater->source()->isNewVersionAvailable()) {
|
||||
//if($updater->source()->isNewVersionAvailable()) {
|
||||
|
||||
// Get the new version available
|
||||
$versionAvailable = $updater->source()->getVersionAvailable();
|
||||
@ -76,7 +76,7 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
$updater->source()->update($release);
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
$cacheCompiled = base_path('bootstrap/cache/compiled.php');
|
||||
if (file_exists($cacheCompiled)) { unlink ($cacheCompiled); }
|
||||
|
@ -28,9 +28,8 @@ class SubdomainController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subdomain_exists = MultiDB::findAndSetDbByDomain(request()->input('subdomain'));
|
||||
|
||||
if($subdomain_exists)
|
||||
if( MultiDB::findAndSetDbByDomain(request()->input('subdomain')) )
|
||||
return response()->json(['message' => 'Domain not available'] , 401);
|
||||
|
||||
return response()->json(['message' => 'Domain available'], 200);
|
||||
|
@ -192,6 +192,15 @@ class Import implements ShouldQueue
|
||||
$array = json_decode(file_get_contents($this->file_path), 1);
|
||||
$data = $array['data'];
|
||||
|
||||
|
||||
// disable some functionality here:
|
||||
// 1. disable update_products
|
||||
|
||||
$update_product_state = $this->company->update_products;
|
||||
|
||||
$this->company->update_products = false;
|
||||
$this->company->save();
|
||||
|
||||
foreach ($this->available_imports as $import) {
|
||||
if (! array_key_exists($import, $data)) {
|
||||
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||
@ -211,9 +220,10 @@ class Import implements ShouldQueue
|
||||
// $this->fixClientBalances();
|
||||
$check_data = CheckCompanyData::dispatchNow($this->company, md5(time()));
|
||||
|
||||
// if($check_data['status'] == 'errors')
|
||||
// throw new ProcessingMigrationArchiveFailed(implode("\n", $check_data));
|
||||
|
||||
//reset functionality here
|
||||
$this->company->update_products = $update_product_state;
|
||||
$this->company->save();
|
||||
|
||||
try{
|
||||
Mail::to($this->user->email, $this->user->name())
|
||||
->send(new MigrationCompleted($this->company, implode("<br>",$check_data)));
|
||||
@ -224,7 +234,12 @@ class Import implements ShouldQueue
|
||||
|
||||
/*After a migration first some basic jobs to ensure the system is up to date*/
|
||||
VersionCheck::dispatch();
|
||||
CompanySizeCheck::dispatch();
|
||||
|
||||
//company size check
|
||||
if ($this->company->invoices()->count() > 1000 || $this->company->products()->count() > 1000 || $this->company->clients()->count() > 1000) {
|
||||
$company->is_large = true;
|
||||
$company->save();
|
||||
}
|
||||
|
||||
info('Completed🚀🚀🚀🚀🚀 at '.now());
|
||||
|
||||
|
@ -16,6 +16,7 @@ use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
@ -293,10 +294,17 @@ class MultiDB
|
||||
{
|
||||
/* This will set the database connection for the request */
|
||||
config(['database.default' => $database]);
|
||||
|
||||
// for some reason this breaks everything _hard_
|
||||
// DB::purge($database);
|
||||
// DB::reconnect($database);
|
||||
}
|
||||
|
||||
public static function setDefaultDatabase()
|
||||
{
|
||||
config(['database.default' => config('ninja.db.default')]);
|
||||
|
||||
// DB::purge(config('ninja.db.default'));
|
||||
// DB::reconnect(config('ninja.db.default'));
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,11 @@ class Task extends BaseModel
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
return $this->belongsTo(TaskStatus::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
|
@ -22,6 +22,7 @@ class TaskRepository extends BaseRepository
|
||||
{
|
||||
use GeneratesCounter;
|
||||
|
||||
public $new_task = true;
|
||||
|
||||
/**
|
||||
* Saves the task and its contacts.
|
||||
@ -33,10 +34,15 @@ class TaskRepository extends BaseRepository
|
||||
*/
|
||||
public function save(array $data, Task $task) : ?Task
|
||||
{
|
||||
if($task->id)
|
||||
$this->new_task = false;
|
||||
|
||||
$task->fill($data);
|
||||
$task->save();
|
||||
|
||||
if($this->new_task && !$task->status_id)
|
||||
$this->setDefaultStatus($task);
|
||||
|
||||
$task->number = empty($task->number) || !array_key_exists('number', $data) ? $this->getNextTaskNumber($task) : $data['number'];
|
||||
|
||||
if (isset($data['description'])) {
|
||||
@ -103,6 +109,19 @@ class TaskRepository extends BaseRepository
|
||||
|
||||
}
|
||||
|
||||
private function setDefaultStatus(Task $task)
|
||||
{
|
||||
$first_status = $task->company->task_statuses()
|
||||
->whereNull('deleted_at')
|
||||
->orderBy('id','asc')
|
||||
->first();
|
||||
|
||||
if($first_status)
|
||||
return $first_status->id;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the task status order IF the old status has changed between requests
|
||||
*
|
||||
|
@ -35,12 +35,12 @@ class ProductFactory extends Factory
|
||||
'cost' => $this->faker->numberBetween(1, 1000),
|
||||
'price' => $this->faker->numberBetween(1, 1000),
|
||||
'quantity' => $this->faker->numberBetween(1, 100),
|
||||
'tax_name1' => 'GST',
|
||||
'tax_rate1' => 10,
|
||||
'tax_name2' => 'VAT',
|
||||
'tax_rate2' => 17.5,
|
||||
'tax_name3' => 'THIRDTAX',
|
||||
'tax_rate3' => 5,
|
||||
// 'tax_name1' => 'GST',
|
||||
// 'tax_rate1' => 10,
|
||||
// 'tax_name2' => 'VAT',
|
||||
// 'tax_rate2' => 17.5,
|
||||
// 'tax_name3' => 'THIRDTAX',
|
||||
// 'tax_rate3' => 5,
|
||||
'custom_value1' => $this->faker->text(20),
|
||||
'custom_value2' => $this->faker->text(20),
|
||||
'custom_value3' => $this->faker->text(20),
|
||||
|
@ -90,6 +90,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
Route::put('invoices/{invoice}/upload', 'InvoiceController@upload')->name('invoices.upload');
|
||||
Route::get('invoice/{invitation_key}/download', 'InvoiceController@downloadPdf')->name('invoices.downloadPdf');
|
||||
Route::post('invoices/bulk', 'InvoiceController@bulk')->name('invoices.bulk');
|
||||
|
||||
Route::post('logout', 'LogoutController@index')->name('logout');
|
||||
|
||||
Route::post('migrate', 'MigrationController@index')->name('migrate.start');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user