add active class for nav
This commit is contained in:
parent
9a6405e418
commit
6857cad565
@ -1,6 +1,11 @@
|
||||
#account_main{
|
||||
menu{
|
||||
width: 10rem;
|
||||
display: flex;
|
||||
#account_nav{
|
||||
width: 20rem;
|
||||
padding: 1rem;
|
||||
|
||||
}
|
||||
#account_main_content{
|
||||
width: 30rem;
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,17 @@
|
||||
}
|
||||
a{
|
||||
@extend .clickable;
|
||||
padding: 0.5rem 1rem;
|
||||
display: inline-block;
|
||||
color: $primary_color;
|
||||
text-decoration: none;
|
||||
&:hover{
|
||||
color: $primary_color_darker;
|
||||
}
|
||||
&.active{
|
||||
background: $bg_active_link;
|
||||
color: $active_link_text;
|
||||
}
|
||||
}
|
||||
button{
|
||||
@extend .clickable;
|
||||
|
@ -2,3 +2,5 @@ $bg_color:lightgray;
|
||||
$bg_main_color: white;
|
||||
$primary_color: #98c87e;
|
||||
$primary_color_darker: #537b3d;
|
||||
$bg_active_link: $primary_color_darker;
|
||||
$active_link_text: white;
|
||||
|
@ -1,4 +1,7 @@
|
||||
security:
|
||||
role_hierarchy:
|
||||
ROLE_ADMIN: ROLE_USER
|
||||
ROLE_SUPER_ADMIN: [ ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]
|
||||
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
||||
password_hashers:
|
||||
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
||||
@ -18,7 +21,13 @@ security:
|
||||
provider: app_user_provider
|
||||
# by default, the feature allows 5 login attempts per minute
|
||||
# login_throttling: null
|
||||
|
||||
remember_me:
|
||||
secret: '%kernel.secret%' # required
|
||||
lifetime: 604800 # 1 week in seconds
|
||||
# by default, the feature is enabled by checking a
|
||||
# checkbox in the login form (see below), uncomment the
|
||||
# following line to always enable it.
|
||||
#always_remember_me: true
|
||||
# configure the maximum login attempts
|
||||
login_throttling:
|
||||
max_attempts: 3 # per minute ...
|
||||
@ -45,6 +54,7 @@ security:
|
||||
access_control:
|
||||
- { path: ^/admin, roles: ROLE_ADMIN }
|
||||
- { path: ^/profile, roles: ROLE_USER }
|
||||
- { path: ^/account, roles: ROLE_USER }
|
||||
|
||||
when@test:
|
||||
security:
|
||||
|
31
migrations/Version20240716092119.php
Normal file
31
migrations/Version20240716092119.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20240716092119 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE user ADD last_login DATE DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE `user` DROP last_login');
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@ class AccountController extends AbstractController
|
||||
'controller_name' => 'AccountController',
|
||||
]);
|
||||
}
|
||||
/***
|
||||
page d'exemple
|
||||
**/
|
||||
#[Route('/account/history', name: 'app_account_history')]
|
||||
public function history(): Response
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
@ -21,8 +22,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\Column(length: 180, unique: true)]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(length: 500, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private array $roles = [];
|
||||
@ -36,6 +35,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\Column(type: 'boolean')]
|
||||
private $isVerified = false;
|
||||
|
||||
#[ORM\Column(length: 500, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $last_login = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -117,4 +122,28 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastLogin(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->last_login;
|
||||
}
|
||||
|
||||
public function setLastLogin(?\DateTimeInterface $last_login): static
|
||||
{
|
||||
$this->last_login = $last_login;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
<div id="account_home">
|
||||
|
||||
<h1>
|
||||
Mon compte
|
||||
Tableau de bord
|
||||
</h1>
|
||||
<a href="{{ app_account }}">modifier mes informations</a>
|
||||
<a href="{{ path('app_account') }}">modifier mes informations (todo)</a>
|
||||
<p>
|
||||
Coucou {{ app.user.email }}!
|
||||
</p>
|
||||
|
@ -1,16 +1,21 @@
|
||||
{% set currentRoute = app.request.attributes.get('_route') %}
|
||||
<div id="nav_menu">
|
||||
<nav>
|
||||
<div class="mb-3">
|
||||
<a href="{{ path('app_index') }}">Accueil</a>
|
||||
<a href="{{ path('app_index') }}"
|
||||
class="{% if currentRoute == 'app_index' %}active{% endif %}"
|
||||
>{{ 'common.homepage'|trans }}</a>
|
||||
{% if app.user %}
|
||||
|
||||
You are logged in as
|
||||
<a class="account-link" href="{{ path('app_account') }}">{{ app.user.userIdentifier }}</a>
|
||||
, <a href="{{ path('app_logout') }}">Logout</a>
|
||||
<a
|
||||
class="account-link {% if currentRoute == 'app_account' %}active{% endif %}"
|
||||
href="{{ path('app_account') }}">{{ app.user.userIdentifier }}</a>
|
||||
, <a href="{{ path('app_logout') }}">{{ 'user.logout'|trans }}</a>
|
||||
|
||||
{% else %}
|
||||
<a href="{{ path('app_login') }}">{{ 'user.login'|trans }}</a>
|
||||
<a href="{{ path('app_register') }}">Register</a>
|
||||
<a class="account-link {% if currentRoute == 'app_login' %}active{% endif %}"
|
||||
href="{{ path('app_login') }}">{{ 'user.login'|trans }}</a>
|
||||
<a class="account-link {% if currentRoute == 'app_register' %}active{% endif %}"
|
||||
href="{{ path('app_register') }}">{{ 'user.register'|trans }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{# <a href="{{path('admin')}}">Admin</a> #}
|
||||
|
@ -3,18 +3,10 @@
|
||||
{% block title %}Hello IndexController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello ! ✅</h1>
|
||||
|
||||
This friendly message is coming from:
|
||||
<ul>
|
||||
<li>Your controller at <code><a href="{{ '/home/poule/encrypted/stockage-syncable/www/development/html/sf-with-users/userlands/src/Controller/IndexController.php'|file_link(0) }}">src/Controller/IndexController.php</a></code></li>
|
||||
<li>Your template at <code><a href="{{ '/home/poule/encrypted/stockage-syncable/www/development/html/sf-with-users/userlands/templates/index/index.html.twig'|file_link(0) }}">templates/index/index.html.twig</a></code></li>
|
||||
</ul>
|
||||
<h1>{{ 'pages.app_index.title'|trans }}</h1>
|
||||
<p>
|
||||
{{ 'pages.app_index.subtitle'|trans }}
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -38,7 +38,10 @@
|
||||
If you want to control the URL the user is redirected to on success
|
||||
#}
|
||||
<input type="hidden" name="_target_path" value="/account">
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="_remember_me" checked>
|
||||
Keep me logged in
|
||||
</label>
|
||||
<button class="btn btn-lg btn-primary" type="submit">
|
||||
Sign in
|
||||
</button>
|
||||
|
@ -1 +1,11 @@
|
||||
|
||||
common:
|
||||
homepage: Accueil
|
||||
pages:
|
||||
app_index:
|
||||
title: Salutations noble barbare!
|
||||
subtitle: Bienvenue dans cette application Symfony capable de gérer un espace utilisateur.
|
||||
user:
|
||||
# id is user.login
|
||||
login: Login
|
||||
logout: Se déconnecter
|
||||
register: Créer un compte
|
||||
|
Loading…
Reference in New Issue
Block a user