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
|
|
|
private $initDone = false; |
15
|
|
|
/** |
16
|
|
|
* @var \Hybrid_Auth |
17
|
|
|
*/ |
18
|
|
|
private $hybridAuth; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var ParameterBag |
22
|
|
|
*/ |
23
|
|
|
private $requestQuery; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Process the current request. |
27
|
|
|
* |
28
|
|
|
* $request - The current request parameters. Leave as NULL to default to use $_REQUEST. |
29
|
|
|
* |
30
|
|
|
* @param Request $request |
31
|
|
|
* |
32
|
|
|
* @return RedirectResponse|Response |
33
|
|
|
*/ |
34
|
|
|
public function processAction(Request $request) |
35
|
|
|
{ |
36
|
|
|
// //Get the request Vars |
37
|
|
|
// $this->requestQuery = $request->query; |
38
|
|
|
// |
39
|
|
|
// // init the hybridAuth instance |
40
|
|
|
// $provider = trim(strip_tags($this->requestQuery->get('hauth_start'))); |
41
|
|
|
$provider = 'linkedin'; |
42
|
|
|
$cookieName = $this->getAzineHybridAuthService()->getCookieName($provider); |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
$adapter = $this->getAzineHybridAuthService()->getInstance($request->cookies->get($cookieName), $provider); |
46
|
|
|
|
47
|
|
|
try { |
48
|
|
|
$adapter->authenticate(); |
49
|
|
|
$this->getAzineHybridAuthService()->storeHybridAuthSessionData($request, $provider, json_encode($adapter->getAccessToken())); |
50
|
|
|
} catch (\Exception $e) { |
51
|
|
|
throw new \Exception("Unable to create adapter for provider '$provider'. Is it configured properly?", $e->getCode(), $e); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$response = new RedirectResponse($this->generateUrl('user_edit')); |
55
|
|
|
|
56
|
|
|
return $response; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return AzineHybridAuth |
61
|
|
|
*/ |
62
|
|
|
private function getAzineHybridAuthService() |
63
|
|
|
{ |
64
|
|
|
return $this->get('azine_hybrid_auth_service'); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.