|
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
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
14
|
|
|
$apiKeyHead= $request->headers->get('apikey'); |
|
|
|
|
|
|
15
|
|
|
$accessToken = $request->headers->get('token'); |
|
16
|
|
|
|
|
17
|
|
|
if ($accessToken){ |
|
18
|
|
|
$UserFacebook = $this->get('service_facebook_sdk')->setValue($accessToken)->getValue(); |
|
19
|
|
|
|
|
20
|
|
|
$apiKey=uniqid('token_'); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
$userFind = $em->getRepository('AppBundle:Customer') |
|
23
|
|
|
->findUserByFacebookId($UserFacebook->getId()); |
|
24
|
|
|
dump($userFind); |
|
|
|
|
|
|
25
|
|
|
die(); |
|
|
|
|
|
|
26
|
|
|
if($userFind){ |
|
|
|
|
|
|
27
|
|
|
$userRefreshApikey = $em->getRepository('AppBundle:Customer') |
|
28
|
|
|
->find($userFind[0]['id']); |
|
29
|
|
|
$userRefreshApikey->setApiKey($apiKey); |
|
30
|
|
|
$em->persist($userRefreshApikey); |
|
31
|
|
|
$em->flush($userRefreshApikey); |
|
32
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
else { |
|
35
|
|
|
$userFindApiKey = $em->getRepository('AppBundle:Customer') |
|
36
|
|
|
->findUsernameByApiKey($apiKeyHead); |
|
37
|
|
|
|
|
38
|
|
|
$userRefreshAll= $em->getRepository('AppBundle:Customer') |
|
39
|
|
|
->find($userFindApiKey[0]['id']); |
|
40
|
|
|
|
|
41
|
|
|
dump($userFindApiKey); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$userRefreshAll->setEmail($UserFacebook->getEmail()); |
|
46
|
|
|
$userRefreshAll->setFacebookID($UserFacebook->getId()); |
|
47
|
|
|
$Key = rand(100000, 500000); |
|
48
|
|
|
$apiKey = (string)$Key; |
|
49
|
|
|
$ugserRefreshAll->setApiKey($apiKey); |
|
50
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
51
|
|
|
$em->persist($userRefreshAll); |
|
52
|
|
|
$em->flush(); |
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
else{ |
|
|
|
|
|
|
58
|
|
|
//add first, last name or refreshAll |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
return $this->render(':default:login.html.twig'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.