Compare commits
2 Commits
325d986505
...
3510e66882
Author | SHA1 | Date |
---|---|---|
wpetit | 3510e66882 | |
wpetit | a311d67f39 |
|
@ -4,8 +4,8 @@ namespace App\Controller;
|
|||
use App\Http\DataResponse;
|
||||
use App\Http\ErrorResponse;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class SecurityController extends Controller
|
||||
|
@ -18,12 +18,7 @@ class SecurityController extends Controller
|
|||
$user = $this->getUser();
|
||||
|
||||
if ($user == null) {
|
||||
return new ErrorResponse(
|
||||
0,
|
||||
"Identifiants invalides",
|
||||
null,
|
||||
401,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DataResponse([
|
||||
|
|
|
@ -22,6 +22,18 @@ class UserController extends Controller
|
|||
return new DataResponse([
|
||||
'username' => $user->getUsername(),
|
||||
'roles' => $user->getRoles(),
|
||||
'projects' => $user->getProjects()->map(function($project) {
|
||||
return [
|
||||
'id' => $project->getId(),
|
||||
'name' => $project->getName(),
|
||||
];
|
||||
})->toArray(),
|
||||
'requests' => $user->getRequests()->map(function($request) {
|
||||
return [
|
||||
'id' => $request->getId(),
|
||||
'title' => $request->getTitle(),
|
||||
];
|
||||
})->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue