- Restriction UI warning

- create folder restriction
- fixed UI bugs
This commit is contained in:
Čarodej
2022-01-05 12:48:07 +01:00
parent c7c11fe5b9
commit b4887cea0e
21 changed files with 306 additions and 71 deletions
@@ -15,8 +15,7 @@ class FixedBillingLimitationEngine implements LimitationEngine
);
// Check if storage usage exceed predefined capacity
return ! ($usedPercentage >= 100)
;
return ! ($usedPercentage >= 100);
}
public function canDownload(User $user): bool
@@ -9,21 +9,18 @@ class MeteredBillingLimitationEngine implements LimitationEngine
public function canUpload(User $user, int $fileSize = 0): bool
{
// Disable upload when user has more than 3 failed payments
return ! ($user->failedPayments()->count() >= 3)
;
return ! ($user->failedPayments()->count() >= 3);
}
public function canDownload(User $user): bool
{
// Disable upload when user has more than 3 failed payments
return ! ($user->failedPayments()->count() >= 3)
;
// Disable download when user has more than 3 failed payments
return ! ($user->failedPayments()->count() >= 3);
}
public function canCreateFolder(User $user): bool
{
// Disable upload when user has more than 3 failed payments
return ! ($user->failedPayments()->count() >= 3)
;
// Disable create folder when user has more than 3 failed payments
return ! ($user->failedPayments()->count() >= 3);
}
}
@@ -0,0 +1,10 @@
<?php
namespace App\Users\Exceptions;
use Exception;
class InvalidUserActionException extends Exception
{
// TODO: translate
protected $message = 'This user action is not allowed.';
}
+11 -11
View File
@@ -88,17 +88,6 @@ class User extends Authenticatable implements MustVerifyEmail
return UserFactory::new();
}
public function __call($method, $parameters)
{
if (str_starts_with($method, 'can')) {
return resolve(LimitationManager::class)
->driver()
->$method($this, ...$parameters);
}
return parent::__call($method, $parameters);
}
/**
* Get user used storage details
*/
@@ -211,6 +200,17 @@ class User extends Authenticatable implements MustVerifyEmail
$this->notify(new ResetPassword($token));
}
public function __call($method, $parameters)
{
if (str_starts_with($method, 'can')) {
return resolve(LimitationManager::class)
->driver()
->$method($this, ...$parameters);
}
return parent::__call($method, $parameters);
}
protected static function boot()
{
parent::boot();