transition
This commit is contained in:
@@ -13,11 +13,13 @@ use Lucent\Account\AuthService;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Svelte\Svelte;
|
||||
use Lucent\Util\Form\FormException;
|
||||
use Lucent\Util\Form\ResponseFormError;
|
||||
use function Lucent\Response\fail;
|
||||
use function Lucent\Response\ok;
|
||||
|
||||
|
||||
class AuthController extends Controller
|
||||
class AuthController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AuthService $authService,
|
||||
@@ -65,52 +67,39 @@ class AuthController extends Controller
|
||||
return ok();
|
||||
}
|
||||
|
||||
public function login(): View|RedirectResponse
|
||||
public function login()
|
||||
{
|
||||
|
||||
if ($this->accountService->countUsers() == 0) {
|
||||
return redirect($this->channelService->channel->lucentUrl . "/register");
|
||||
}
|
||||
|
||||
return $this->svelte->render(
|
||||
layout: "account",
|
||||
view: "login",
|
||||
title: "Log in"
|
||||
);
|
||||
return view("lucent::auth.login");
|
||||
}
|
||||
|
||||
public function postLogin(Request $request): Response
|
||||
public function postLogin(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->authService->sendLoginEmail($request->input("email"));
|
||||
} catch (LucentException $th) {
|
||||
return fail($th);
|
||||
}
|
||||
$this->authService->sendLoginEmail($request->input("email"));
|
||||
|
||||
return ok();
|
||||
return view("lucent::auth.login-success");
|
||||
}
|
||||
|
||||
public function verify(Request $request): View
|
||||
{
|
||||
return $this->svelte->render(
|
||||
layout: "account",
|
||||
view: "verify",
|
||||
title: "Verify and enter",
|
||||
data: [
|
||||
"email" => $request->input("email"),
|
||||
"token" => $request->input("token"),
|
||||
]
|
||||
);
|
||||
return view("lucent::auth.verify", [
|
||||
"email" => $request->input("email"),
|
||||
"token" => $request->input("token"),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function postVerify(Request $request): Response
|
||||
public function postVerify(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->authService->login($request->input("email"), $request->input("token"));
|
||||
} catch (LucentException $th) {
|
||||
return fail($th);
|
||||
return ResponseFormError::fromException($th);
|
||||
}
|
||||
return ok();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,14 +21,36 @@ class HomeController extends Controller
|
||||
{
|
||||
}
|
||||
|
||||
public function home(): View
|
||||
public function home(Request $request): View
|
||||
{
|
||||
$urlParams = $request->all();
|
||||
$users = $this->accountService->all();
|
||||
|
||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
$arguments = array_merge([
|
||||
"schema_in" => $this->accountService->currentReadableSchemas(),
|
||||
"status_in" => ["draft", "published"]
|
||||
], $filter);
|
||||
|
||||
$limit = 10;
|
||||
|
||||
$graph = $this->query
|
||||
->filter($arguments)
|
||||
->limit($limit)
|
||||
->childrenDepth(1)
|
||||
->parentsDepth(0)
|
||||
->sort($sort)
|
||||
->run();
|
||||
|
||||
|
||||
return view("lucent::home", [
|
||||
"users" => $users,
|
||||
"records" => $graph->getRootRecords(),
|
||||
"graph" => toArray($graph),
|
||||
"modalUrl" => $request->fullUrl(),
|
||||
]);
|
||||
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "homeIndex",
|
||||
title: "Records",
|
||||
);
|
||||
}
|
||||
|
||||
public function records(Request $request): Response
|
||||
|
||||
Reference in New Issue
Block a user