1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Azine\HybridAuthBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
7
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Hybridauth\HttpClient\Util; |
11
|
|
|
|
12
|
|
|
class HybridEndPointController extends Controller |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var ParameterBag |
16
|
|
|
*/ |
17
|
|
|
private $requestQuery; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Process the current request. |
21
|
|
|
* |
22
|
|
|
* $request - The current request parameters. Leave as NULL to default to use $_REQUEST. |
23
|
|
|
* |
24
|
|
|
* @param Request $request |
25
|
|
|
* |
26
|
|
|
* @return RedirectResponse|Response |
27
|
|
|
*/ |
28
|
|
|
public function processAction(Request $request) |
29
|
|
|
{ |
30
|
|
|
$provider = 'linkedin'; |
31
|
|
|
$cookieName = $this->getAzineHybridAuthService()->getCookieName($provider); |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
$adapter = $this->getAzineHybridAuthService()->getInstance($request->cookies->get($cookieName), $provider); |
35
|
|
|
|
36
|
|
|
try { |
37
|
|
|
$adapter->authenticate(); |
38
|
|
|
$result = $this->getAzineHybridAuthService()->storeHybridAuthSessionData($request, $provider, json_encode($adapter->getAccessToken())); |
39
|
|
|
} catch (\Exception $e) { |
40
|
|
|
throw new \Exception("Unable to create adapter for provider '$provider'. Is it configured properly?", $e->getCode(), $e); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$response = new RedirectResponse($this->generateUrl('user_edit')); |
44
|
|
|
|
45
|
|
|
if($result instanceof Cookie){ |
|
|
|
|
46
|
|
|
|
47
|
|
|
$response->headers->setCookie($result); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $response; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return AzineHybridAuth |
55
|
|
|
*/ |
56
|
|
|
private function getAzineHybridAuthService() |
57
|
|
|
{ |
58
|
|
|
return $this->get('azine_hybrid_auth_service'); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.