permissions finito

This commit is contained in:
2023-10-18 01:54:24 +03:00
parent 632684f514
commit 91b68d9682
5 changed files with 125 additions and 109 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"main.js": {
"file": "assets/main.6a78412a.js",
"file": "assets/main.f9100565.js",
"src": "main.js",
"isEntry": true,
"css": [
-2
View File
@@ -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,
)
{
+16 -1
View File
@@ -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
{
+2
View File
@@ -24,6 +24,8 @@ readonly class AuthMiddleware
return redirect($this->channelService->channel->lucentUrl . "/login");
}
$this->authService->refreshSession();
return $next($request);
}