react-logo/backend/src/Controller/SecurityController.php

24 lines
624 B
PHP
Raw Normal View History

2020-02-17 22:28:57 +01:00
<?php
namespace App\Controller;
use App\Http\DataResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class SecurityController extends Controller
{
/**
* @Route("/api/v1/login", name="api_v1_login", methods={"POST"})
*/
public function login(Request $request)
{
$user = $this->getUser();
return new DataResponse([
'username' => $user->getUsername(),
'roles' => $user->getRoles(),
]);
}
}