This commit is contained in:
Andras Bacsai
2023-07-14 12:09:56 +02:00
parent a96fb46296
commit 9f4342bd19
16 changed files with 100 additions and 49 deletions

View File

@@ -19,10 +19,22 @@ class Controller extends BaseController
public function subscription()
{
if (!isCloud()) {
abort(404);
}
return view('subscription', [
'settings' => InstanceSettings::get()
]);
}
public function license()
{
if (!isCloud()) {
abort(404);
}
return view('settings.license', [
'settings' => InstanceSettings::get()
]);
}
public function dashboard()
{
$projects = Project::ownedByCurrentTeam()->get();

View File

@@ -35,7 +35,7 @@ class CheckLicense extends Component
} catch (\Throwable $th) {
session()->flash('error', 'License is not valid. Please contact support.');
ray($th->getMessage());
return redirect()->to('/subscription');
return redirect()->to('/settings/license');
}
}
}

View File

@@ -11,27 +11,31 @@ class SubscriptionValid
public function handle(Request $request, Closure $next): Response
{
$allowed_paths = [
'subscription',
'login',
'register',
'logout',
'livewire/message/check-license',
'livewire/message/switch-team',
];
if (isCloud() && !isSubscribed()) {
ray('SubscriptionValid Middleware');
if (!in_array($request->path(), $allowed_paths)) {
return redirect('subscription');
if (auth()->user()) {
if (isCloud() && !isSubscribed()) {
ray('SubscriptionValid Middleware');
$allowed_paths = [
'subscription',
'login',
'register',
'logout',
'livewire/message/check-license',
'livewire/message/switch-team',
];
if (!in_array($request->path(), $allowed_paths)) {
return redirect('subscription');
} else {
return $next($request);
}
} else {
return $next($request);
}
} else {
if ($request->path() === 'subscription') {
return redirect('/');
} else {
return $next($request);
if ($request->path() === 'subscription' && !auth()->user()->isInstanceAdmin()) {
return redirect('/');
} else {
return $next($request);
}
}
}
return $next($request);
}
}

View File

@@ -18,6 +18,7 @@ class InstanceSettings extends Model implements SendsEmail
];
protected $casts = [
'smtp' => SchemalessAttributes::class,
'resale_license' => 'encrypted',
];
public function scopeWithSmtp(): Builder
{

View File

@@ -16,13 +16,12 @@ class Input extends Component
public string|null $type = 'text',
public string|null $value = null,
public string|null $label = null,
public string|null $placeholder = null,
public bool $required = false,
public bool $disabled = false,
public bool $readonly = false,
public string|null $helper = null,
public bool $allowToPeak = true,
public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none"
public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none placeholder:text-coolgray-500"
) {
}