Redirect monCompte API
This commit is contained in:
@@ -250,6 +250,7 @@ fos_rest:
|
||||
serialize_null: true
|
||||
format_listener:
|
||||
rules:
|
||||
- { path: '^/api/talent', priorities: ['html'], fallback_format: 'html' }
|
||||
- { path: '^/api/', priorities: ['json'], fallback_format: 'json' }
|
||||
param_fetcher_listener: true
|
||||
exception:
|
||||
@@ -264,6 +265,22 @@ lexik_jwt_authentication:
|
||||
public_key: '%kernel.root_dir%/../app/config/jwt/public.pem' # required for token verification
|
||||
pass_phrase: 'talentstubeforever' # required for token creation, usage of an environment variable is recommended
|
||||
token_ttl: 3600000
|
||||
token_extractors:
|
||||
# look for a token as Authorization Header
|
||||
authorization_header:
|
||||
enabled: true
|
||||
prefix: Bearer
|
||||
name: Authorization
|
||||
|
||||
# check token in a cookie
|
||||
cookie:
|
||||
enabled: false
|
||||
name: BEARER
|
||||
|
||||
# check token in query string parameter
|
||||
query_parameter:
|
||||
enabled: true
|
||||
name: bearer
|
||||
|
||||
nelmio_cors:
|
||||
paths:
|
||||
|
||||
@@ -15,6 +15,14 @@ use FOS\UserBundle\Model\UserInterface;
|
||||
use AppBundle\Entity\Company;
|
||||
use AppBundle\Exception\ResourceValidationException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use AppBundle\Form\ContactTalentType;
|
||||
use AppBundle\Form\MediaType;
|
||||
use AppBundle\Form\TalentProfileType;
|
||||
use AppBundle\Form\TalentType;
|
||||
use AppBundle\Form\CareersType;
|
||||
use AppBundle\Form\FormationsType;
|
||||
use AppBundle\Form\LanguagesType;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
|
||||
class SecurityController extends FOSRestController
|
||||
{
|
||||
@@ -554,4 +562,25 @@ class SecurityController extends FOSRestController
|
||||
$data = json_decode($response);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Rest\Get(path="/api/talent", name="api_talent")
|
||||
* @Rest\View
|
||||
*/
|
||||
public function goToMonCompte(Request $request)
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
|
||||
$this->get('security.token_storage')->setToken($token);
|
||||
|
||||
$this->get('session')->set('_security_main', serialize($token));
|
||||
|
||||
$event = new InteractiveLoginEvent($request, $token);
|
||||
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
|
||||
|
||||
$view = $this->redirectView($this->generateUrl('talent_dashboard'), 301);
|
||||
|
||||
return $this->handleView($view);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user