Commit baa5658b authored by Vincent Mazenod's avatar Vincent Mazenod
Browse files

change home page and redirect to job after login

parent b88349b6
......@@ -19,6 +19,8 @@ security:
form_login:
login_path: login
check_path: login
default_target_path: job
always_use_default_target_path: true
logout:
path: logout
guard:
......
......@@ -11,11 +11,11 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
class DocsController extends AbstractController
{
/**
* @Route("/about", name="about")
* @Route("/", name="home")
*/
public function about()
public function home()
{
return $this->render('docs/about.html.twig');
return $this->render('docs/home.html.twig');
}
/**
......
......@@ -24,7 +24,7 @@ use App\Services\ConstraintMining;
class JobController extends AbstractController
{
/**
* @Route("/{id<\d+>}", name="home", defaults={"id"=0})
* @Route("/job/{id<\d+>}", name="job", defaults={"id"=0})
* @IsGranted("ROLE_USER")
*/
public function list(
......
......@@ -25,7 +25,6 @@ class SecurityController extends AbstractController
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
$form = $this->createForm(LoginFormType::class, new User());
return $this->render('security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
......@@ -85,7 +84,7 @@ class SecurityController extends AbstractController
$this->addFlash('warning', 'an email was sent to '.$email);
return $this->redirectToRoute('home');
return $this->redirectToRoute('job');
}
return $this->render('security/forgotten_password.html.twig');
......@@ -125,7 +124,7 @@ class SecurityController extends AbstractController
$this->addFlash('success', 'Password updated');
return $this->redirectToRoute('home');
return $this->redirectToRoute('job');
}
return $this->render(
......
......@@ -48,7 +48,7 @@ class UserController extends AbstractController
$entityManager->flush();
$this->addFlash('succes', 'Password updated');
return $this->redirectToRoute('home');
return $this->redirectToRoute('job');
}
return $this->render('user/profile.html.twig', [
......
......@@ -81,12 +81,8 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
return new RedirectResponse($targetPath);
}
// For example : return new RedirectResponse($this->urlGenerator->generate('some_route'));
return new RedirectResponse($this->urlGenerator->generate('home'));
// inefficient see config/packages/security.yaml default_target_path & always_use_default_target_path keys
return new RedirectResponse($this->urlGenerator->generate('job'));
}
protected function getLoginUrl()
......
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand"
href="{{ path('home') }}">
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<a class="navbar-brand" href="{{ path('job') }}">
{% else %}
<a class="navbar-brand" href="{{ path('home') }}">
{% endif %}
<i class="fas fa-cogs"></i>
Mobipaleo
</a>
......@@ -23,12 +26,12 @@
<li class="nav-item">
<a class="nav-link
{% if app.request.attributes.get('_route') == 'about' %}
{% if app.request.attributes.get('_route') == 'home' %}
active
{% endif %}"
href="{{ path('about') }}">
href="{{ path('home') }}">
<i class="fas fa-star-of-life"></i>
about
home
</a>
</li>
......@@ -93,7 +96,7 @@
{% if app.request.attributes.get('_route') starts with 'job' %}
active
{% endif %}"
href="{{ path('home') }}">
href="{{ path('job') }}">
<i class="fas fa-cogs"></i>
jobs
</a>
......
......@@ -24,7 +24,7 @@
{% if is_granted('ROLE_ADMIN') %}
<a class="btn btn-primary btn-circle btn-sm"
href="{{ path('home', { 'id': job.user.id }) }}">
href="{{ path('job', { 'id': job.user.id }) }}">
<i class="far fa-user-circle"></i> {{ job.user.email }}
</a>
{% endif %}
......
......@@ -22,13 +22,13 @@
<tr>
<td>
<a class="btn btn-primary btn-circle btn-sm"
href="{{ path('home', { 'id': user.id }) }}">
href="{{ path('job', { 'id': user.id }) }}">
<i class="far fa-user-circle"></i>
{{ user.email }}
</a>
</td>
<td>
<a href="{{ path('home', {
<a href="{{ path('job', {
'id': user.id
}) }}">
{{ user.jobs | length }}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment