|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
7
|
|
|
|
|
8
|
|
|
class CustomerController extends Controller |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
public function customersLoginAction(Request $request) |
|
12
|
|
|
{ |
|
13
|
|
|
$apiKeyHead= $request->headers->get('apikey'); |
|
14
|
|
|
$accessToken = $request->headers->get('token'); |
|
15
|
|
|
|
|
16
|
|
|
if ($accessToken){ |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
$UserFacebook = $this->get('service_facebook_sdk'); |
|
21
|
|
|
$UserFacebook->setValue($accessToken); |
|
22
|
|
|
|
|
23
|
|
|
$UserFacebook = $UserFacebook->getValue(); |
|
24
|
|
|
//dump($UserFacebook); |
|
25
|
|
|
echo $UserFacebook->getId(); |
|
26
|
|
|
|
|
27
|
|
|
$Key=rand(100000,500000); |
|
28
|
|
|
$apiKey=(string) $Key; |
|
29
|
|
|
|
|
30
|
|
|
$em=$this->getDoctrine()->getManager(); |
|
31
|
|
|
$userFind = $em->getRepository('AppBundle:Customer') |
|
32
|
|
|
->findUserByFacebookId($UserFacebook->getId()); |
|
33
|
|
|
if($userFind){ |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
$userRefreshApikey = $em->getRepository('AppBundle:Customer') |
|
37
|
|
|
->find($userFind[0]['id']); |
|
38
|
|
|
$userRefreshApikey->setApiKey($apiKey); |
|
39
|
|
|
$em->persist($userRefreshApikey); |
|
40
|
|
|
$em->flush($userRefreshApikey); |
|
41
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
else { |
|
44
|
|
|
$em=$this->getDoctrine()->getManager(); |
|
45
|
|
|
$userFindApiKey = $em->getRepository('AppBundle:Customer') |
|
46
|
|
|
->findUsernameByApiKey($apiKeyHead); |
|
47
|
|
|
|
|
48
|
|
|
$userRefreshAll= $em->getRepository('AppBundle:Customer') |
|
49
|
|
|
->find($userFindApiKey[0]['id']); |
|
50
|
|
|
|
|
51
|
|
|
dump($userFindApiKey); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$userRefreshAll->setEmail($UserFacebook->getEmail()); |
|
56
|
|
|
$userRefreshAll->setFacebookID($UserFacebook->getId()); |
|
57
|
|
|
$Key = rand(100000, 500000); |
|
58
|
|
|
$apiKey = (string)$Key; |
|
59
|
|
|
$userRefreshAll->setApiKey($apiKey); |
|
60
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
61
|
|
|
$em->persist($userRefreshAll); |
|
62
|
|
|
$em->flush(); |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
else{ |
|
|
|
|
|
|
68
|
|
|
//add first, last name or refreshAll |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
return $this->render(':default:login.html.twig'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for function calls that miss required arguments.