permissions finito
This commit is contained in:
+106
-105
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"main.js": {
|
||||
"file": "assets/main.6a78412a.js",
|
||||
"file": "assets/main.f9100565.js",
|
||||
"src": "main.js",
|
||||
"isEntry": true,
|
||||
"css": [
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Lucent\Account;
|
||||
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\Primitive\Collection;
|
||||
use Lucent\Schema\SchemaService;
|
||||
|
||||
readonly class AccountService
|
||||
{
|
||||
@@ -12,7 +11,6 @@ readonly class AccountService
|
||||
public function __construct(
|
||||
private AuthService $authService,
|
||||
private ChannelService $channelService,
|
||||
private SchemaService $schemaService,
|
||||
private UserRepo $userRepo,
|
||||
)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ readonly class AuthService
|
||||
$user = $this->userRepo->findByEmail(new Email($email));
|
||||
|
||||
if ($user->isEmpty()) {
|
||||
throw new LucentException("You account was not found");
|
||||
throw new LucentException("Your account was not found");
|
||||
}
|
||||
|
||||
if ($user->get()->isRemoved()) {
|
||||
@@ -74,6 +74,21 @@ readonly class AuthService
|
||||
$this->session->put(["user" => $user->get()->safe()]);
|
||||
}
|
||||
|
||||
public function refreshSession(){
|
||||
$user = $this->userRepo->findById($this->currentUserId());
|
||||
|
||||
if ($user->isEmpty()) {
|
||||
throw new LucentException("Your account was not found");
|
||||
}
|
||||
|
||||
if ($user->get()->isRemoved()) {
|
||||
throw new LucentException("Your account is not active");
|
||||
}
|
||||
|
||||
$newUser = $user->get();
|
||||
$this->session->put(["user" => $user->get()->safe()]);
|
||||
}
|
||||
|
||||
|
||||
public function create(string $name, string $email, array $roles): User
|
||||
{
|
||||
|
||||
@@ -24,6 +24,8 @@ readonly class AuthMiddleware
|
||||
return redirect($this->channelService->channel->lucentUrl . "/login");
|
||||
}
|
||||
|
||||
$this->authService->refreshSession();
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user