Commit a9a33efb authored by Mat's avatar Mat

résoud le bug de construction des nom de fichiers d'avatars

parent 4e93c90f
......@@ -45,14 +45,13 @@ class ChatController extends Controller
{
// traitement de l'avatar, avac un nom unique
$filename = md5(uniqid() . '.' . $user->getFile()->guessExtension());
$filename = md5(uniqid()) . '_' . $user->getFile()->getClientOriginalName();
$user->getFile()->move(
$this->getParameter('avatar_directory'),
$filename
);
$user->setAvatar($filename);
$user->setRole(["ROLE_USER"]); // on affecte un rôle
$pwd = $encoder->encodePassword($user, $user->getPassword());
......
<style>
img.avatar {
li {
list-style: none;
margin-bottom: 0.3em;
}
li span {
vertical-align: middle;
}
ul {
padding: 0;
}
li img.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
vertical-align: middle;
margin-right: 0.3em;
}
</style>
<ul>
......@@ -10,12 +22,12 @@
{# @var user \SocketBundle\Entity\User #}
{# pour avoir l'autocomplétion #}
<li>
{{ user.username }}
<img src="{{ 'http://0.0.0.0:81/web/assets/img/avatar/' ~ user.avatar | default('default.jpg') }}" alt="avatar" class="avatar">
{#
normalement, asset() retourne 'localhost/tbws/web/'
mais avec web socket, asset() retourne juste 'localhost'
#}
<span>{{ user.username }}</span>
</li>
{% endfor %}
</ul>
......@@ -6,6 +6,8 @@
</head>
<body>
<a href="{{ path('register') }}">Register</a>
<form action="{{ path('login-check') }}" method="post">
{% if error != null %}
......
<a href="{{ path('login') }}">Login</a>
{{ form_start(form) }}
{# ASTUCE
......
Markdown is supported
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