Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vimazeno
mobipaleo
Commits
baa5658b
Commit
baa5658b
authored
Nov 19, 2021
by
Vincent Mazenod
Browse files
change home page and redirect to job after login
parent
b88349b6
Changes
10
Hide whitespace changes
Inline
Side-by-side
config/packages/security.yaml
View file @
baa5658b
...
...
@@ -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
:
...
...
src/Controller/DocsController.php
View file @
baa5658b
...
...
@@ -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'
);
}
/**
...
...
src/Controller/JobController.php
View file @
baa5658b
...
...
@@ -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
(
...
...
src/Controller/SecurityController.php
View file @
baa5658b
...
...
@@ -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
(
...
...
src/Controller/UserController.php
View file @
baa5658b
...
...
@@ -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'
,
[
...
...
src/Security/LoginFormAuthenticator.php
View file @
baa5658b
...
...
@@ -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
()
...
...
templates/docs/
about
.html.twig
→
templates/docs/
home
.html.twig
View file @
baa5658b
File moved
templates/inc/header.html.twig
View file @
baa5658b
<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>
...
...
templates/job/inc/card.html.twig
View file @
baa5658b
...
...
@@ -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
%}
...
...
templates/user/list.html.twig
View file @
baa5658b
...
...
@@ -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
}}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment