mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
Auth Framework, Part 2
Auth class is back up and running to handle user authorizaion as well as session managment. Implemented basic usage on admin index class just for an example. Added a couple of new template files and css to start defining the overall style of pages and UI.
This commit is contained in:
@ -8,37 +8,56 @@ namespace App\Controller\Routes\Back;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
//use App\Utils\PageRender;
|
||||
//use App\Data\Auth;
|
||||
use App\Service\Auth;
|
||||
|
||||
class Index extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/screendoor", name="back-index")
|
||||
* @Route("/den", name="back-index")
|
||||
*/
|
||||
public function showBackIndex(Request $request): Response
|
||||
public function enterTheDen(Request $request, Auth $auth, RequestStack $requestStack): Response
|
||||
{
|
||||
return $this->render("back/index.twig", [
|
||||
"title" => "Close the door behind you",
|
||||
]);
|
||||
/*
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
return $render->renderPage(
|
||||
[
|
||||
"bgImage" => "/images/base/tweed-flowers.png",
|
||||
"role" => $result["role"],
|
||||
],
|
||||
"The Nile List | Welcome Back",
|
||||
"front/index.html.twig"
|
||||
);
|
||||
} else {
|
||||
//back to index to login
|
||||
header("Location:/login");
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
}
|
||||
*/
|
||||
if ($request->getMethod() == "GET") {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
$session = $requestStack->getSession();
|
||||
$member = $session->get("member");
|
||||
return $this->render("back/start.twig", [
|
||||
"title" => "Welcome Back",
|
||||
"handle" => $member->getHandle()
|
||||
]);
|
||||
} else {
|
||||
return $this->render("back/index.twig", [
|
||||
"title" => "Close the door behind you",
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//handles login
|
||||
$handle = $request->request->get("handle");
|
||||
$pass = $request->request->get("password");
|
||||
$result = $auth->authCheck($handle, $pass);
|
||||
if ($result["status"]) {
|
||||
header("Location:/den");
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
} else {
|
||||
return $this->render("back/index.twig", [
|
||||
"title" => "Close the door behind you",
|
||||
"notice" => $result["message"]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/logout", name="logout-page")
|
||||
*/
|
||||
public function leaveTheDen(Auth $auth)
|
||||
{
|
||||
$auth->logout();
|
||||
header("Location:/den");
|
||||
return new Response("<html><body>LOGGED OUT</body></html>");
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class Members extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/screendoor/members/add", name="members-add")
|
||||
* @Route("/den/members/add", name="members-add")
|
||||
*/
|
||||
public function addMembers(
|
||||
Request $request,
|
||||
|
Reference in New Issue
Block a user