diff --git a/config/routes.yaml b/config/routes.yaml index 921a7c6..7c8c0a1 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -6,9 +6,17 @@ # path: / # controller: App\Controller\SecurityController::login -hometown: +#homepage: + #path: / + #controller: App\Controller\SecurityController::login + +home: path: / - controller: App\Controller\SecurityController::login + controller: App\Controller\SecurityController::sitemap + +sitemap: + path: /sitemap + controller: App\Controller\SecurityController::sitemap post_ledger: path: /post diff --git a/public/assets/css/style.css b/public/assets/css/style.css index ca40aa0..43c55b2 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -38,5 +38,5 @@ nav { #login-container { margin-left: 25%; - margin-top: 15%; + margin-top: 5%; } diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index b32a784..01a8042 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -14,12 +14,10 @@ class SecurityController extends AbstractController */ public function login(AuthenticationUtils $authenticationUtils): Response { - // if ($this->getUser()) { - // return $this->redirectToRoute('target_path'); - // } // get the login error if there is one $error = $authenticationUtils->getLastAuthenticationError(); + // last username entered by the user $lastUsername = $authenticationUtils->getLastUsername(); @@ -34,4 +32,9 @@ public function logout() return $this->redirectToRoute('app_login'); throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } + + public function sitemap() + { + return $this->render('sitemap.html.twig'); + } } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 8d59f6f..a04944b 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -137,6 +137,8 @@ public function delete(Request $request, User $user): Response $entityManager = $this->getDoctrine()->getManager(); $entityManager->remove($user); $entityManager->flush(); + + $this->_delete_yourself(); } } return $this->redirectToRoute('user_index'); @@ -144,4 +146,10 @@ public function delete(Request $request, User $user): Response return $this->redirectToRoute('app_login'); } } + + private function _delete_yourself(){ + // if you delete yourself, automatically, destroy session and logout + session_destroy(); + return $this->redirectToRoute('app_login'); + } } diff --git a/src/Form/PostType.php b/src/Form/PostType.php index efa5fb4..d673490 100644 --- a/src/Form/PostType.php +++ b/src/Form/PostType.php @@ -16,7 +16,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder ->add('title', TextType::class, ['attr' => ['class' => 'form-control', 'maxlength' => 32]]) ->add('body', TextAreaType::class, - ['attr' => ['class' => 'form-control', 'cols' => 4, 'maxlength' =>255]] + ['attr' => ['class' => 'form-control', 'cols' => 5, 'maxlength' =>255]] ); } diff --git a/templates/base.html.twig b/templates/base.html.twig index 0ca448d..7be3e92 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -74,6 +74,10 @@ Posts +
  • + Site Map +
  • +
  • Logout
  • diff --git a/templates/post/index.html.twig b/templates/post/index.html.twig index 6fb1238..9bf9340 100644 --- a/templates/post/index.html.twig +++ b/templates/post/index.html.twig @@ -15,7 +15,7 @@ ID USER TITLE - BODY snippet + BODY snippet DATE @@ -39,7 +39,7 @@ {% else %} -

    There are no posts submitted.

    + info_outline There are no posts submitted. {% endfor %} diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig index 2b3ef66..2dde04a 100644 --- a/templates/security/login.html.twig +++ b/templates/security/login.html.twig @@ -10,7 +10,7 @@
    {% if app.user %}
    -

    You are logged in as {{ app.user.username }}, Logout

    +

    You are logged in as {{ app.user.username }}, Logout

    {% endif %} @@ -23,11 +23,11 @@
    - +
    - +
    diff --git a/templates/sitemap.html.twig b/templates/sitemap.html.twig new file mode 100644 index 0000000..50c314f --- /dev/null +++ b/templates/sitemap.html.twig @@ -0,0 +1,51 @@ +{% extends 'base.html.twig' %} + +{% block title %}Site Map{% endblock %} + +{% block body %} +
    +
    + {% if app.user == null %} +

    info_outline You are not currently logged in. You can view Site Map as a directory.

    + {% endif %} + +

    view_headline Site Map

    + +

    + info_outline Don't forget to clear cache! $_ php bin/console cache:clear +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    UsersPostsMisc
    ledgerledgerlogin
    addaddlogout
    editedit
    profileprofile
    +
    +
    +{% endblock %} diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig index 7559f15..ac8c5f6 100644 --- a/templates/user/index.html.twig +++ b/templates/user/index.html.twig @@ -39,7 +39,7 @@ {% else %} -

    info_outline There are no registered users.

    + info_outline There are no registered users. {% endfor %}