Passed
Push — master ( 60b1cb...62a444 )
by Anthony
07:00
created
Form/Type/AutocompleteType.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
                 ],
21 21
                 "mapped" => false
22 22
             ])
23
-            ->add($options["autocomplete_name"]."_id", HiddenType::class, [
23
+            ->add($options["autocomplete_name"] . "_id", HiddenType::class, [
24 24
                 "mapped" => false
25 25
             ]);
26 26
     }
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@
 block discarded – undo
10 10
 
11 11
 class AutocompleteType extends AbstractType
12 12
 {
13
-    public function buildForm(FormBuilderInterface $builder, array $options)
14
-    {
15
-        $builder
16
-            ->add($options["autocomplete_name"], TextType::class, [
17
-                "label" => false,
18
-                "attr" => [
19
-                    "class" => "input-autocomplete",
20
-                    "data-url" => $options["data_url"],
21
-                    "autocomplete" => "off"
22
-                ],
23
-                "mapped" => false
24
-            ])
25
-            ->add($options["autocomplete_name"]."_id", HiddenType::class, [
26
-                "mapped" => false
27
-            ]);
28
-    }
13
+				public function buildForm(FormBuilderInterface $builder, array $options)
14
+				{
15
+								$builder
16
+												->add($options["autocomplete_name"], TextType::class, [
17
+																"label" => false,
18
+																"attr" => [
19
+																				"class" => "input-autocomplete",
20
+																				"data-url" => $options["data_url"],
21
+																				"autocomplete" => "off"
22
+																],
23
+																"mapped" => false
24
+												])
25
+												->add($options["autocomplete_name"]."_id", HiddenType::class, [
26
+																"mapped" => false
27
+												]);
28
+				}
29 29
 
30
-    public function configureOptions(OptionsResolver $resolver)
31
-    {
32
-        $resolver->setDefaults([
33
-            "autocomplete_name" => null,
34
-            "data_url" => null,
35
-        ]);
36
-    }
30
+				public function configureOptions(OptionsResolver $resolver)
31
+				{
32
+								$resolver->setDefaults([
33
+												"autocomplete_name" => null,
34
+												"data_url" => null,
35
+								]);
36
+				}
37 37
 }
Please login to merge, or discard this patch.
Entity/AccountToken.php 1 patch
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -15,154 +15,154 @@
 block discarded – undo
15 15
  */
16 16
 class AccountToken
17 17
 {
18
-    /**
19
-     * @ORM\Id
20
-     * @ORM\Column(type="integer")
21
-     * @ORM\GeneratedValue(strategy="AUTO")
22
-     */
23
-    protected $id;
24
-
25
-    /**
26
-     * @ORM\Column(type="string", length=200)
27
-     */
28
-    protected $token;
29
-
30
-    /**
31
-     * @ORM\Column(type="datetime", nullable=true)
32
-     */
33
-    protected $endToken;
34
-
35
-    /**
36
-     * @ORM\Column(type="string", length=200)
37
-     */
38
-    protected $userAgent;
39
-
40
-    /**
41
-     * @ORM\Column(type="string", length=200)
42
-     */
43
-    protected $ip;
44
-
45
-    /**
46
-     * @ORM\ManyToOne(targetEntity="Account", inversedBy="tokens")
47
-     * @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
48
-     */
49
-    protected $account;
50
-
51
-    /**
52
-     * @return mixed
53
-     */
54
-    public function getId()
55
-    {
56
-        return $this->id;
57
-    }
58
-
59
-    /**
60
-     * @param mixed $id
61
-     * @return AccountToken
62
-     */
63
-    public function setId($id)
64
-    {
65
-        $this->id = $id;
66
-
67
-        return $this;
68
-    }
69
-
70
-    /**
71
-     * @return mixed
72
-     */
73
-    public function getToken()
74
-    {
75
-        return $this->token;
76
-    }
77
-
78
-    /**
79
-     * @param mixed $token
80
-     * @return AccountToken
81
-     */
82
-    public function setToken($token)
83
-    {
84
-        $this->token = $token;
85
-
86
-        return $this;
87
-    }
88
-
89
-    /**
90
-     * @return mixed
91
-     */
92
-    public function getEndToken()
93
-    {
94
-        return $this->endToken;
95
-    }
96
-
97
-    /**
98
-     * @param mixed $endToken
99
-     * @return AccountToken
100
-     */
101
-    public function setEndToken($endToken)
102
-    {
103
-        $this->endToken = $endToken;
104
-
105
-        return $this;
106
-    }
107
-
108
-    /**
109
-     * @return mixed
110
-     */
111
-    public function getUserAgent()
112
-    {
113
-        return $this->userAgent;
114
-    }
115
-
116
-    /**
117
-     * @param mixed $userAgent
118
-     * @return AccountToken
119
-     */
120
-    public function setUserAgent($userAgent)
121
-    {
122
-        $this->userAgent = $userAgent;
123
-
124
-        return $this;
125
-    }
126
-
127
-    /**
128
-     * @return mixed
129
-     */
130
-    public function getIp()
131
-    {
132
-        return $this->ip;
133
-    }
134
-
135
-    /**
136
-     * @param mixed $ip
137
-     * @return AccountToken
138
-     */
139
-    public function setIp($ip)
140
-    {
141
-        $this->ip = $ip;
142
-
143
-        return $this;
144
-    }
145
-
146
-    /**
147
-     * Set Account entity (many to one).
148
-     *
149
-     * @param Account $account
150
-     * @return AccountToken
151
-     */
152
-    public function setAccount(Account $account = null)
153
-    {
154
-        $this->account = $account;
155
-
156
-        return $this;
157
-    }
158
-
159
-    /**
160
-     * Get Account entity (many to one).
161
-     *
162
-     * @return Account
163
-     */
164
-    public function getAccount()
165
-    {
166
-        return $this->account;
167
-    }
18
+				/**
19
+				 * @ORM\Id
20
+				 * @ORM\Column(type="integer")
21
+				 * @ORM\GeneratedValue(strategy="AUTO")
22
+				 */
23
+				protected $id;
24
+
25
+				/**
26
+				 * @ORM\Column(type="string", length=200)
27
+				 */
28
+				protected $token;
29
+
30
+				/**
31
+				 * @ORM\Column(type="datetime", nullable=true)
32
+				 */
33
+				protected $endToken;
34
+
35
+				/**
36
+				 * @ORM\Column(type="string", length=200)
37
+				 */
38
+				protected $userAgent;
39
+
40
+				/**
41
+				 * @ORM\Column(type="string", length=200)
42
+				 */
43
+				protected $ip;
44
+
45
+				/**
46
+				 * @ORM\ManyToOne(targetEntity="Account", inversedBy="tokens")
47
+				 * @ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
48
+				 */
49
+				protected $account;
50
+
51
+				/**
52
+				 * @return mixed
53
+				 */
54
+				public function getId()
55
+				{
56
+								return $this->id;
57
+				}
58
+
59
+				/**
60
+				 * @param mixed $id
61
+				 * @return AccountToken
62
+				 */
63
+				public function setId($id)
64
+				{
65
+								$this->id = $id;
66
+
67
+								return $this;
68
+				}
69
+
70
+				/**
71
+				 * @return mixed
72
+				 */
73
+				public function getToken()
74
+				{
75
+								return $this->token;
76
+				}
77
+
78
+				/**
79
+				 * @param mixed $token
80
+				 * @return AccountToken
81
+				 */
82
+				public function setToken($token)
83
+				{
84
+								$this->token = $token;
85
+
86
+								return $this;
87
+				}
88
+
89
+				/**
90
+				 * @return mixed
91
+				 */
92
+				public function getEndToken()
93
+				{
94
+								return $this->endToken;
95
+				}
96
+
97
+				/**
98
+				 * @param mixed $endToken
99
+				 * @return AccountToken
100
+				 */
101
+				public function setEndToken($endToken)
102
+				{
103
+								$this->endToken = $endToken;
104
+
105
+								return $this;
106
+				}
107
+
108
+				/**
109
+				 * @return mixed
110
+				 */
111
+				public function getUserAgent()
112
+				{
113
+								return $this->userAgent;
114
+				}
115
+
116
+				/**
117
+				 * @param mixed $userAgent
118
+				 * @return AccountToken
119
+				 */
120
+				public function setUserAgent($userAgent)
121
+				{
122
+								$this->userAgent = $userAgent;
123
+
124
+								return $this;
125
+				}
126
+
127
+				/**
128
+				 * @return mixed
129
+				 */
130
+				public function getIp()
131
+				{
132
+								return $this->ip;
133
+				}
134
+
135
+				/**
136
+				 * @param mixed $ip
137
+				 * @return AccountToken
138
+				 */
139
+				public function setIp($ip)
140
+				{
141
+								$this->ip = $ip;
142
+
143
+								return $this;
144
+				}
145
+
146
+				/**
147
+				 * Set Account entity (many to one).
148
+				 *
149
+				 * @param Account $account
150
+				 * @return AccountToken
151
+				 */
152
+				public function setAccount(Account $account = null)
153
+				{
154
+								$this->account = $account;
155
+
156
+								return $this;
157
+				}
158
+
159
+				/**
160
+				 * Get Account entity (many to one).
161
+				 *
162
+				 * @return Account
163
+				 */
164
+				public function getAccount()
165
+				{
166
+								return $this->account;
167
+				}
168 168
 }
Please login to merge, or discard this patch.
Repository/AccountTokenRepository.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
8 8
 
9 9
 class AccountTokenRepository extends EntityRepository
10 10
 {
11
-    /**
12
-     * method to find UserToken to archive
13
-     * @param int $max_inactivation_days
14
-     * @return mixed
15
-     * @throws Exception
16
-     */
17
-    public function findByExpiredToken(int $max_inactivation_days)
18
-    {
19
-        $now = new \DateTime();
20
-        $now->sub(new \DateInterval("P" . $max_inactivation_days . "D"));
11
+				/**
12
+				 * method to find UserToken to archive
13
+				 * @param int $max_inactivation_days
14
+				 * @return mixed
15
+				 * @throws Exception
16
+				 */
17
+				public function findByExpiredToken(int $max_inactivation_days)
18
+				{
19
+								$now = new \DateTime();
20
+								$now->sub(new \DateInterval("P" . $max_inactivation_days . "D"));
21 21
 
22
-        $query = $this->getEntityManager()->createQuery("SELECT u FROM App:AccountToken u WHERE
22
+								$query = $this->getEntityManager()->createQuery("SELECT u FROM App:AccountToken u WHERE
23 23
 			u.endToken < :max_inactivation_days
24 24
 		");
25 25
 
26
-        $query->setParameter("max_inactivation_days", $now, Type::DATETIME);
26
+								$query->setParameter("max_inactivation_days", $now, Type::DATETIME);
27 27
 
28
-        return $query->getResult();
29
-    }
28
+								return $query->getResult();
29
+				}
30 30
 }
Please login to merge, or discard this patch.
Controller/ApiController.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
13 13
 
14 14
 class ApiController extends AbstractController
15 15
 {
16
-    /**
17
-     * this method is user to authenticate a user by an api request
18
-     * if success it return a token api that expire in 20 minutes
19
-     * @Route("/api/users/authenticate", name="ribsadmin_api_login", methods={"POST"})
20
-     * @param Request $request
21
-     * @param Api $api
22
-     * @param EncoderFactoryInterface $encoder
23
-     * @return JsonResponse
24
-     * @throws \Exception
25
-     */
16
+				/**
17
+				 * this method is user to authenticate a user by an api request
18
+				 * if success it return a token api that expire in 20 minutes
19
+				 * @Route("/api/users/authenticate", name="ribsadmin_api_login", methods={"POST"})
20
+				 * @param Request $request
21
+				 * @param Api $api
22
+				 * @param EncoderFactoryInterface $encoder
23
+				 * @return JsonResponse
24
+				 * @throws \Exception
25
+				 */
26 26
 	public function login(Request $request, Api $api, EncoderFactoryInterface $encoder): JsonResponse
27 27
 	{
28 28
 		$em = $this->getDoctrine()->getManager();
@@ -55,29 +55,29 @@  discard block
 block discarded – undo
55 55
 		]);
56 56
 	}
57 57
 
58
-    /**
59
-     * method that test if user steel logged and send token or new token if it was expired
60
-     * @Route("/api/users/test-token", name="ribsadmin_api_test_token", methods={"POST"})
61
-     * @param Request $request
62
-     * @param Api $api
63
-     * @param Session $session
64
-     * @return JsonResponse
65
-     * @throws \Exception
66
-     */
67
-    public function testUserToken(Request $request, Api $api, Session $session): JsonResponse
68
-    {
69
-        $test_logged = $api->userIslogged($request->get("infos"), $request->get("token"));
58
+				/**
59
+				 * method that test if user steel logged and send token or new token if it was expired
60
+				 * @Route("/api/users/test-token", name="ribsadmin_api_test_token", methods={"POST"})
61
+				 * @param Request $request
62
+				 * @param Api $api
63
+				 * @param Session $session
64
+				 * @return JsonResponse
65
+				 * @throws \Exception
66
+				 */
67
+				public function testUserToken(Request $request, Api $api, Session $session): JsonResponse
68
+				{
69
+								$test_logged = $api->userIslogged($request->get("infos"), $request->get("token"));
70 70
 
71
-        if ($test_logged === false) {
72
-            return new JsonResponse([
73
-                "success" => $test_logged,
74
-                "error_message" => "Votre compte a été archivé, vous ne pouvez plus vous connecter",
75
-            ]);
76
-        }
71
+								if ($test_logged === false) {
72
+												return new JsonResponse([
73
+																"success" => $test_logged,
74
+																"error_message" => "Votre compte a été archivé, vous ne pouvez plus vous connecter",
75
+												]);
76
+								}
77 77
 
78
-        return new JsonResponse([
79
-            "success" => $test_logged,
80
-            "token" => $api->getToken($session->get("account")),
81
-        ]);
82
-    }
78
+								return new JsonResponse([
79
+												"success" => $test_logged,
80
+												"token" => $api->getToken($session->get("account")),
81
+								]);
82
+				}
83 83
 }
Please login to merge, or discard this patch.
Service/Api.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -23,192 +23,192 @@
 block discarded – undo
23 23
 
24 24
 class Api
25 25
 {
26
-    /**
27
-     * @var ContainerInterface
28
-     */
29
-    private $container;
30
-
31
-    /**
32
-     * @var EntityManagerInterface
33
-     */
34
-    private $em;
35
-
36
-    /**
37
-     * @var SessionInterface
38
-     */
39
-    private $session;
40
-
41
-    /**
42
-     * @var Account
43
-     */
44
-    private $account;
45
-
46
-    /**
47
-     * @var Request|null
48
-     */
49
-    private $request;
50
-
51
-    /**
52
-     * Api constructor.
53
-     * @param ContainerInterface $container
54
-     * @param EntityManagerInterface $em
55
-     * @param SessionInterface $session
56
-     * @param RequestStack $request_stack
57
-     */
58
-    public function __construct(ContainerInterface $container, EntityManagerInterface $em, SessionInterface $session, RequestStack $request_stack)
59
-    {
60
-        $this->container = $container;
61
-        $this->em = $em;
62
-        $this->session = $session;
63
-        $this->request = $request_stack->getCurrentRequest();
64
-    }
65
-
66
-    /**
67
-     * this method is used to test jwt and if the account is ok else send false
68
-     * @param string $infos_jwt
69
-     * @param string $token
70
-     * @return bool
71
-     * @throws Exception
72
-     */
73
-    public function userIslogged(string $infos_jwt, string $token): bool
74
-    {
75
-        $em = $this->em;
76
-        $jwt = Jwt::decode($infos_jwt, $token);
77
-
78
-        if ($jwt === false) {
79
-            return false;
80
-        }
81
-
82
-        $account_token_search = [
83
-            "token" => $token,
84
-            "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85
-            "ip" => $this->request->server->get("REMOTE_ADDR")
86
-        ];
87
-        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
88
-            $account_token_search = [
89
-                "token" => $token,
90
-                "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
91
-            ];
92
-        }
93
-
94
-        $account_token = $em->getRepository(AccountToken::class)->findOneBy($account_token_search);
95
-
96
-        if (!$account_token) {
97
-            return false;
98
-        }
99
-
100
-        $this->account = $em->getRepository(Account::class)->findOneBy([
101
-            "id" => $account_token->getAccount()->getId(),
102
-            "isActive" => true,
103
-        ]);
104
-
105
-        if (!$this->account) {
106
-            return false;
107
-        }
108
-
109
-        $this->account->setLastConnection(new \DateTime());
110
-        $em->persist($this->account);
111
-        $em->flush();
112
-
113
-        $this->getToken($this->account);
114
-        $this->session->set("jwt_infos", $jwt);
115
-        $this->session->set("account", $this->account);
116
-        $this->session->set("account_token", $account_token);
117
-
118
-        return true;
119
-    }
120
-
121
-    /**
122
-     * method that return the token for a account
123
-     * @param Account $account
124
-     * @return string
125
-     * @throws Exception
126
-     */
127
-    public function getToken(Account $account): string
128
-    {
129
-        $account_token = $this->em->getRepository(AccountToken::class)->findOneBy([
130
-            "account" => $account,
131
-            "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
132
-            "ip" => $this->request->server->get("REMOTE_ADDR")
133
-        ]);
134
-
135
-        $token = $account_token ? $account_token->getToken() : null;
136
-        $now = new \DateTime();
137
-
138
-        if ($token === null || $account_token->getEndToken() < $now) {
139
-            return $this->setToken($account, $account_token);
140
-        }
141
-
142
-        return $token;
143
-    }
144
-
145
-    /**
146
-     * @param Account $account
147
-     * @param $account_token
148
-     * @return string
149
-     * method that set a token for the account
150
-     * @throws Exception
151
-     */
152
-    public function setToken(Account $account, $account_token): string
153
-    {
154
-        $token = $this->generateToken();
155
-        $now = new \DateTime();
156
-        $end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
157
-
158
-        if (!$account_token) {
159
-            $account_token = new AccountToken();
160
-        }
161
-
162
-        $account_token->setToken($token);
163
-        $account_token->setUserAgent($this->request->server->get("HTTP_USER_AGENT"));
164
-        $account_token->setIp($this->request->server->get("REMOTE_ADDR"));
165
-        $account_token->setEndToken($end_token);
166
-        $account_token->setAccount($account);
167
-        $this->em->persist($account_token);
168
-        $this->em->flush();
169
-
170
-        $this->account = $account;
171
-        $this->session->set("account", $this->account);
172
-        $this->session->set("account_token", $account_token);
173
-
174
-        return $token;
175
-    }
176
-
177
-    /**
178
-     * generate a token for api
179
-     * @param int $length
180
-     * @return string
181
-     */
182
-    public function generateToken(int $length = 200): string
183
-    {
184
-        $string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185
-        $token = "";
186
-        srand((double)microtime() * 1000000);
187
-        for ($i = 0; $i < $length; $i++) {
188
-            $token .= $string[rand() % strlen($string)];
189
-        }
190
-
191
-        return $token;
192
-    }
193
-
194
-    /**
195
-     * method that encode an object to a json
196
-     * @param $object
197
-     * @param string $type
198
-     * @return mixed
199
-     * @throws ExceptionInterface
200
-     * @throws AnnotationException
201
-     */
202
-    public function serializeObject($object, $type = "json")
203
-    {
204
-        $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
205
-        $serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206
-
207
-        return $serializer->normalize($object, $type, [
208
-            'circular_reference_handler' => function ($object) {
209
-                return $object->getId();
210
-            },
211
-            'groups' => 'main'
212
-        ]);
213
-    }
26
+				/**
27
+				 * @var ContainerInterface
28
+				 */
29
+				private $container;
30
+
31
+				/**
32
+				 * @var EntityManagerInterface
33
+				 */
34
+				private $em;
35
+
36
+				/**
37
+				 * @var SessionInterface
38
+				 */
39
+				private $session;
40
+
41
+				/**
42
+				 * @var Account
43
+				 */
44
+				private $account;
45
+
46
+				/**
47
+				 * @var Request|null
48
+				 */
49
+				private $request;
50
+
51
+				/**
52
+				 * Api constructor.
53
+				 * @param ContainerInterface $container
54
+				 * @param EntityManagerInterface $em
55
+				 * @param SessionInterface $session
56
+				 * @param RequestStack $request_stack
57
+				 */
58
+				public function __construct(ContainerInterface $container, EntityManagerInterface $em, SessionInterface $session, RequestStack $request_stack)
59
+				{
60
+								$this->container = $container;
61
+								$this->em = $em;
62
+								$this->session = $session;
63
+								$this->request = $request_stack->getCurrentRequest();
64
+				}
65
+
66
+				/**
67
+				 * this method is used to test jwt and if the account is ok else send false
68
+				 * @param string $infos_jwt
69
+				 * @param string $token
70
+				 * @return bool
71
+				 * @throws Exception
72
+				 */
73
+				public function userIslogged(string $infos_jwt, string $token): bool
74
+				{
75
+								$em = $this->em;
76
+								$jwt = Jwt::decode($infos_jwt, $token);
77
+
78
+								if ($jwt === false) {
79
+												return false;
80
+								}
81
+
82
+								$account_token_search = [
83
+												"token" => $token,
84
+												"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85
+												"ip" => $this->request->server->get("REMOTE_ADDR")
86
+								];
87
+								if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
88
+												$account_token_search = [
89
+																"token" => $token,
90
+																"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
91
+												];
92
+								}
93
+
94
+								$account_token = $em->getRepository(AccountToken::class)->findOneBy($account_token_search);
95
+
96
+								if (!$account_token) {
97
+												return false;
98
+								}
99
+
100
+								$this->account = $em->getRepository(Account::class)->findOneBy([
101
+												"id" => $account_token->getAccount()->getId(),
102
+												"isActive" => true,
103
+								]);
104
+
105
+								if (!$this->account) {
106
+												return false;
107
+								}
108
+
109
+								$this->account->setLastConnection(new \DateTime());
110
+								$em->persist($this->account);
111
+								$em->flush();
112
+
113
+								$this->getToken($this->account);
114
+								$this->session->set("jwt_infos", $jwt);
115
+								$this->session->set("account", $this->account);
116
+								$this->session->set("account_token", $account_token);
117
+
118
+								return true;
119
+				}
120
+
121
+				/**
122
+				 * method that return the token for a account
123
+				 * @param Account $account
124
+				 * @return string
125
+				 * @throws Exception
126
+				 */
127
+				public function getToken(Account $account): string
128
+				{
129
+								$account_token = $this->em->getRepository(AccountToken::class)->findOneBy([
130
+												"account" => $account,
131
+												"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
132
+												"ip" => $this->request->server->get("REMOTE_ADDR")
133
+								]);
134
+
135
+								$token = $account_token ? $account_token->getToken() : null;
136
+								$now = new \DateTime();
137
+
138
+								if ($token === null || $account_token->getEndToken() < $now) {
139
+												return $this->setToken($account, $account_token);
140
+								}
141
+
142
+								return $token;
143
+				}
144
+
145
+				/**
146
+				 * @param Account $account
147
+				 * @param $account_token
148
+				 * @return string
149
+				 * method that set a token for the account
150
+				 * @throws Exception
151
+				 */
152
+				public function setToken(Account $account, $account_token): string
153
+				{
154
+								$token = $this->generateToken();
155
+								$now = new \DateTime();
156
+								$end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
157
+
158
+								if (!$account_token) {
159
+												$account_token = new AccountToken();
160
+								}
161
+
162
+								$account_token->setToken($token);
163
+								$account_token->setUserAgent($this->request->server->get("HTTP_USER_AGENT"));
164
+								$account_token->setIp($this->request->server->get("REMOTE_ADDR"));
165
+								$account_token->setEndToken($end_token);
166
+								$account_token->setAccount($account);
167
+								$this->em->persist($account_token);
168
+								$this->em->flush();
169
+
170
+								$this->account = $account;
171
+								$this->session->set("account", $this->account);
172
+								$this->session->set("account_token", $account_token);
173
+
174
+								return $token;
175
+				}
176
+
177
+				/**
178
+				 * generate a token for api
179
+				 * @param int $length
180
+				 * @return string
181
+				 */
182
+				public function generateToken(int $length = 200): string
183
+				{
184
+								$string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185
+								$token = "";
186
+								srand((double)microtime() * 1000000);
187
+								for ($i = 0; $i < $length; $i++) {
188
+												$token .= $string[rand() % strlen($string)];
189
+								}
190
+
191
+								return $token;
192
+				}
193
+
194
+				/**
195
+				 * method that encode an object to a json
196
+				 * @param $object
197
+				 * @param string $type
198
+				 * @return mixed
199
+				 * @throws ExceptionInterface
200
+				 * @throws AnnotationException
201
+				 */
202
+				public function serializeObject($object, $type = "json")
203
+				{
204
+								$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
205
+								$serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206
+
207
+								return $serializer->normalize($object, $type, [
208
+												'circular_reference_handler' => function ($object) {
209
+																return $object->getId();
210
+												},
211
+												'groups' => 'main'
212
+								]);
213
+				}
214 214
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85 85
             "ip" => $this->request->server->get("REMOTE_ADDR")
86 86
         ];
87
-        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
87
+        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $this->request->server->get("HTTP_USER_AGENT")) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($this->request->server->get("HTTP_USER_AGENT"), 0, 4))) {
88 88
             $account_token_search = [
89 89
                 "token" => $token,
90 90
                 "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     {
154 154
         $token = $this->generateToken();
155 155
         $now = new \DateTime();
156
-        $end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
156
+        $end_token = $now->add(new \DateInterval("PT" . $this->container->getParameter("ribs_admin")["api_token_duration"] . "M"));
157 157
 
158 158
         if (!$account_token) {
159 159
             $account_token = new AccountToken();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185 185
         $token = "";
186
-        srand((double)microtime() * 1000000);
186
+        srand((double) microtime() * 1000000);
187 187
         for ($i = 0; $i < $length; $i++) {
188 188
             $token .= $string[rand() % strlen($string)];
189 189
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206 206
 
207 207
         return $serializer->normalize($object, $type, [
208
-            'circular_reference_handler' => function ($object) {
208
+            'circular_reference_handler' => function($object) {
209 209
                 return $object->getId();
210 210
             },
211 211
             'groups' => 'main'
Please login to merge, or discard this patch.
EventListener/CreateUpdateAwareListener.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,30 +12,30 @@
 block discarded – undo
12 12
 	 */
13 13
 	private $user;
14 14
 
15
-    /**
16
-     * CreateUpdateAwareListener constructor.
17
-     * @param TokenStorage $tokenStorage
18
-     */
19
-    public function __construct(TokenStorage $tokenStorage)
15
+				/**
16
+				 * CreateUpdateAwareListener constructor.
17
+				 * @param TokenStorage $tokenStorage
18
+				 */
19
+				public function __construct(TokenStorage $tokenStorage)
20 20
 	{
21
-        $this->user = $tokenStorage->getToken()->getUser()->getUser();
21
+								$this->user = $tokenStorage->getToken()->getUser()->getUser();
22 22
 	}
23 23
 	
24 24
 	public function prePersist($entity)
25 25
 	{
26 26
 		if ($entity->getCreatedBy() === null) {
27
-            $entity->setCreatedAt(new \DateTime());
28
-            $entity->setCreatedBy($this->user);
27
+												$entity->setCreatedAt(new \DateTime());
28
+												$entity->setCreatedBy($this->user);
29 29
 		}
30
-        if ($entity->getUpdatedBy() === null) {
31
-            $entity->setUpdatedAt(new \DateTime());
32
-            $entity->setUpdatedBy($this->user);
33
-        }
30
+								if ($entity->getUpdatedBy() === null) {
31
+												$entity->setUpdatedAt(new \DateTime());
32
+												$entity->setUpdatedBy($this->user);
33
+								}
34 34
 	}
35 35
 
36
-    public function preUpdate($entity)
37
-    {
38
-        $entity->setUpdatedAt(new \DateTime());
39
-        $entity->setUpdatedBy($this->user);
40
-    }
36
+				public function preUpdate($entity)
37
+				{
38
+								$entity->setUpdatedAt(new \DateTime());
39
+								$entity->setUpdatedBy($this->user);
40
+				}
41 41
 }
Please login to merge, or discard this patch.
Entity/Account.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	private $isActive;
46 46
 
47
-    /**
48
-     * @ORM\Column(type="datetime", nullable=true)
49
-     */
50
-    protected $last_connection;
47
+				/**
48
+				 * @ORM\Column(type="datetime", nullable=true)
49
+				 */
50
+				protected $last_connection;
51 51
 
52
-    /**
53
-     * @ORM\OneToMany(targetEntity="AccountToken", mappedBy="account")
54
-     * @ORM\JoinColumn(name="id", referencedColumnName="account_id", nullable=false)
55
-     */
56
-    protected $tokens;
52
+				/**
53
+				 * @ORM\OneToMany(targetEntity="AccountToken", mappedBy="account")
54
+				 * @ORM\JoinColumn(name="id", referencedColumnName="account_id", nullable=false)
55
+				 */
56
+				protected $tokens;
57 57
 	
58 58
 	/**
59 59
 	 * @var User
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	private $user;
67 67
 
68
-    /**
69
-     * @ORM\Column(name="created_at", type="datetime", nullable=true)
70
-     */
71
-    protected $created_at;
68
+				/**
69
+				 * @ORM\Column(name="created_at", type="datetime", nullable=true)
70
+				 */
71
+				protected $created_at;
72 72
 
73
-    /**
74
-     * @ORM\Column(name="created_by", type="integer", nullable=false)
75
-     * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
76
-     * @ORM\JoinColumn(name="created_by", referencedColumnName="id", nullable=false)
77
-     */
78
-    protected $created_by;
73
+				/**
74
+				 * @ORM\Column(name="created_by", type="integer", nullable=false)
75
+				 * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
76
+				 * @ORM\JoinColumn(name="created_by", referencedColumnName="id", nullable=false)
77
+				 */
78
+				protected $created_by;
79 79
 
80
-    /**
81
-     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
82
-     */
83
-    protected $updated_at;
80
+				/**
81
+				 * @ORM\Column(name="updated_at", type="datetime", nullable=true)
82
+				 */
83
+				protected $updated_at;
84 84
 
85
-    /**
86
-     * @ORM\Column(name="updated_by", type="integer", nullable=false)
87
-     * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
88
-     * @ORM\JoinColumn(name="updated_by", referencedColumnName="id", nullable=false)
89
-     */
90
-    protected $updated_by;
85
+				/**
86
+				 * @ORM\Column(name="updated_by", type="integer", nullable=false)
87
+				 * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
88
+				 * @ORM\JoinColumn(name="updated_by", referencedColumnName="id", nullable=false)
89
+				 */
90
+				protected $updated_by;
91 91
 	
92 92
 	public function __construct()
93 93
 	{
@@ -208,43 +208,43 @@  discard block
 block discarded – undo
208 208
 		$this->user = $user;
209 209
 	}
210 210
 
211
-    /**
212
-     * @return mixed
213
-     */
214
-    public function getLastConnection()
215
-    {
216
-        return $this->last_connection;
217
-    }
211
+				/**
212
+				 * @return mixed
213
+				 */
214
+				public function getLastConnection()
215
+				{
216
+								return $this->last_connection;
217
+				}
218 218
 
219
-    /**
220
-     * @param mixed $last_connection
221
-     * @return Account
222
-     */
223
-    public function setLastConnection($last_connection)
224
-    {
225
-        $this->last_connection = $last_connection;
219
+				/**
220
+				 * @param mixed $last_connection
221
+				 * @return Account
222
+				 */
223
+				public function setLastConnection($last_connection)
224
+				{
225
+								$this->last_connection = $last_connection;
226 226
 
227
-        return $this;
228
-    }
227
+								return $this;
228
+				}
229 229
 
230
-    /**
231
-     * @return mixed
232
-     */
233
-    public function getTokens()
234
-    {
235
-        return $this->tokens;
236
-    }
230
+				/**
231
+				 * @return mixed
232
+				 */
233
+				public function getTokens()
234
+				{
235
+								return $this->tokens;
236
+				}
237 237
 
238
-    /**
239
-     * @param mixed $tokens
240
-     * @return Account
241
-     */
242
-    public function setTokens($tokens)
243
-    {
244
-        $this->tokens = $tokens;
238
+				/**
239
+				 * @param mixed $tokens
240
+				 * @return Account
241
+				 */
242
+				public function setTokens($tokens)
243
+				{
244
+								$this->tokens = $tokens;
245 245
 
246
-        return $this;
247
-    }
246
+								return $this;
247
+				}
248 248
 	
249 249
 	/**
250 250
 	 * Returns the roles granted to the user.
@@ -328,81 +328,81 @@  discard block
 block discarded – undo
328 328
 			) = unserialize($serialized);
329 329
 	}
330 330
 
331
-    /**
332
-     * @return mixed
333
-     */
334
-    public function getCreatedAt()
335
-    {
336
-        return $this->created_at;
337
-    }
331
+				/**
332
+				 * @return mixed
333
+				 */
334
+				public function getCreatedAt()
335
+				{
336
+								return $this->created_at;
337
+				}
338 338
 
339
-    /**
340
-     * @param mixed $created_at
341
-     * @return Account
342
-     */
343
-    public function setCreatedAt($created_at): Account
344
-    {
345
-        $this->created_at = $created_at;
339
+				/**
340
+				 * @param mixed $created_at
341
+				 * @return Account
342
+				 */
343
+				public function setCreatedAt($created_at): Account
344
+				{
345
+								$this->created_at = $created_at;
346 346
 
347
-        return $this;
348
-    }
347
+								return $this;
348
+				}
349 349
 
350
-    /**
351
-     * @return mixed
352
-     */
353
-    public function getCreatedBy()
354
-    {
355
-        return $this->created_by;
356
-    }
350
+				/**
351
+				 * @return mixed
352
+				 */
353
+				public function getCreatedBy()
354
+				{
355
+								return $this->created_by;
356
+				}
357 357
 
358
-    /**
359
-     * @ORM\PrePersist
360
-     * @param mixed $created_by
361
-     * @return Account
362
-     */
363
-    public function setCreatedBy($created_by): Account
364
-    {
365
-        $this->created_by = $created_by;
358
+				/**
359
+				 * @ORM\PrePersist
360
+				 * @param mixed $created_by
361
+				 * @return Account
362
+				 */
363
+				public function setCreatedBy($created_by): Account
364
+				{
365
+								$this->created_by = $created_by;
366 366
 
367
-        return $this;
368
-    }
367
+								return $this;
368
+				}
369 369
 
370
-    /**
371
-     * @return mixed
372
-     */
373
-    public function getUpdatedAt()
374
-    {
375
-        return $this->updated_at;
376
-    }
370
+				/**
371
+				 * @return mixed
372
+				 */
373
+				public function getUpdatedAt()
374
+				{
375
+								return $this->updated_at;
376
+				}
377 377
 
378
-    /**
379
-     * @param mixed $updated_at
380
-     * @return Account
381
-     */
382
-    public function setUpdatedAt($updated_at): Account
383
-    {
384
-        $this->updated_at = $updated_at;
378
+				/**
379
+				 * @param mixed $updated_at
380
+				 * @return Account
381
+				 */
382
+				public function setUpdatedAt($updated_at): Account
383
+				{
384
+								$this->updated_at = $updated_at;
385 385
 
386
-        return $this;
387
-    }
386
+								return $this;
387
+				}
388 388
 
389
-    /**
390
-     * @return mixed
391
-     */
392
-    public function getUpdatedBy()
393
-    {
394
-        return $this->updated_by;
395
-    }
389
+				/**
390
+				 * @return mixed
391
+				 */
392
+				public function getUpdatedBy()
393
+				{
394
+								return $this->updated_by;
395
+				}
396 396
 
397
-    /**
398
-     * @ORM\PreUpdate
399
-     * @param mixed $updated_by
400
-     * @return Account
401
-     */
402
-    public function setUpdatedBy($updated_by): Account
403
-    {
404
-        $this->updated_by = $updated_by;
397
+				/**
398
+				 * @ORM\PreUpdate
399
+				 * @param mixed $updated_by
400
+				 * @return Account
401
+				 */
402
+				public function setUpdatedBy($updated_by): Account
403
+				{
404
+								$this->updated_by = $updated_by;
405 405
 
406
-        return $this;
407
-    }
406
+								return $this;
407
+				}
408 408
 }
Please login to merge, or discard this patch.
Entity/User.php 1 patch
Indentation   +307 added lines, -307 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class User
16 16
 {
17
-    /**
18
-     * @var integer
19
-     *
20
-     * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
21
-     * @ORM\Id
22
-     * @ORM\GeneratedValue(strategy="IDENTITY")
23
-     */
24
-    private $id;
25
-
26
-    /**
27
-     * @var string
28
-     *
29
-     * @ORM\Column(name="guid", type="string", length=255, nullable=false)
30
-     */
31
-    private $guid;
17
+				/**
18
+				 * @var integer
19
+				 *
20
+				 * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
21
+				 * @ORM\Id
22
+				 * @ORM\GeneratedValue(strategy="IDENTITY")
23
+				 */
24
+				private $id;
25
+
26
+				/**
27
+				 * @var string
28
+				 *
29
+				 * @ORM\Column(name="guid", type="string", length=255, nullable=false)
30
+				 */
31
+				private $guid;
32 32
 	
33 33
 	/**
34 34
 	 * @var AccessRight
@@ -36,63 +36,63 @@  discard block
 block discarded – undo
36 36
 	 * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\AccessRight", inversedBy="users")
37 37
 	 * @ORM\JoinColumn(name="id_access_right", referencedColumnName="id", nullable=true)
38 38
 	 */
39
-    private $accessRightList;
39
+				private $accessRightList;
40 40
 	
41 41
 	/**
42 42
 	 * @var boolean
43 43
 	 *
44 44
 	 * @ORM\Column(name="admin", type="boolean", nullable=true, options={"default": false})
45 45
 	 */
46
-    private $admin;
47
-
48
-    /**
49
-     * @var string
50
-     *
51
-     * @ORM\Column(name="firstname", type="string", length=255, nullable=false)
52
-     */
53
-    private $firstname;
54
-
55
-    /**
56
-     * @var string
57
-     *
58
-     * @ORM\Column(name="lastname", type="string", length=255, nullable=false)
59
-     */
60
-    private $lastname;
61
-
62
-    /**
63
-     * @var string
64
-     *
65
-     * @ORM\Column(name="adress", type="string", length=255, nullable=true)
66
-     */
67
-    private $adress;
68
-
69
-    /**
70
-     * @var string
71
-     *
72
-     * @ORM\Column(name="postal_code", type="string", length=100, nullable=true)
73
-     */
74
-    private $postalCode;
75
-
76
-    /**
77
-     * @var string
78
-     *
79
-     * @ORM\Column(name="country", type="string", length=100, nullable=true)
80
-     */
81
-    private $country;
82
-
83
-    /**
84
-     * @var string
85
-     *
86
-     * @ORM\Column(name="state", type="string", length=255, nullable=true)
87
-     */
88
-    private $state;
89
-
90
-    /**
91
-     * @var string
92
-     *
93
-     * @ORM\Column(name="access_rights", type="text", nullable=true)
94
-     */
95
-    private $accessRights;
46
+				private $admin;
47
+
48
+				/**
49
+				 * @var string
50
+				 *
51
+				 * @ORM\Column(name="firstname", type="string", length=255, nullable=false)
52
+				 */
53
+				private $firstname;
54
+
55
+				/**
56
+				 * @var string
57
+				 *
58
+				 * @ORM\Column(name="lastname", type="string", length=255, nullable=false)
59
+				 */
60
+				private $lastname;
61
+
62
+				/**
63
+				 * @var string
64
+				 *
65
+				 * @ORM\Column(name="adress", type="string", length=255, nullable=true)
66
+				 */
67
+				private $adress;
68
+
69
+				/**
70
+				 * @var string
71
+				 *
72
+				 * @ORM\Column(name="postal_code", type="string", length=100, nullable=true)
73
+				 */
74
+				private $postalCode;
75
+
76
+				/**
77
+				 * @var string
78
+				 *
79
+				 * @ORM\Column(name="country", type="string", length=100, nullable=true)
80
+				 */
81
+				private $country;
82
+
83
+				/**
84
+				 * @var string
85
+				 *
86
+				 * @ORM\Column(name="state", type="string", length=255, nullable=true)
87
+				 */
88
+				private $state;
89
+
90
+				/**
91
+				 * @var string
92
+				 *
93
+				 * @ORM\Column(name="access_rights", type="text", nullable=true)
94
+				 */
95
+				private $accessRights;
96 96
 	
97 97
 	/**
98 98
 	 * @var boolean
@@ -101,59 +101,59 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	private $archived = false;
103 103
 
104
-    /**
105
-     * @ORM\Column(name="created_at", type="datetime", nullable=true)
106
-     */
107
-    protected $created_at;
108
-
109
-    /**
110
-     * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
111
-     * @ORM\JoinColumn(name="created_by", referencedColumnName="id", nullable=false)
112
-     */
113
-    protected $created_by;
114
-
115
-    /**
116
-     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
117
-     */
118
-    protected $updated_at;
119
-
120
-    /**
121
-     * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
122
-     * @ORM\JoinColumn(name="updated_by", referencedColumnName="id", nullable=false)
123
-     */
124
-    protected $updated_by;
125
-
126
-    /**
127
-     * @return int
128
-     */
129
-    public function getId()
130
-    {
131
-        return $this->id;
132
-    }
133
-
134
-    /**
135
-     * @param int $id
136
-     */
137
-    public function setId($id)
138
-    {
139
-        $this->id = $id;
140
-    }
141
-
142
-    /**
143
-     * @return string
144
-     */
145
-    public function getGuid()
146
-    {
147
-        return $this->guid;
148
-    }
149
-
150
-    /**
151
-     * @param string $guid
152
-     */
153
-    public function setGuid($guid)
154
-    {
155
-        $this->guid = $guid;
156
-    }
104
+				/**
105
+				 * @ORM\Column(name="created_at", type="datetime", nullable=true)
106
+				 */
107
+				protected $created_at;
108
+
109
+				/**
110
+				 * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
111
+				 * @ORM\JoinColumn(name="created_by", referencedColumnName="id", nullable=false)
112
+				 */
113
+				protected $created_by;
114
+
115
+				/**
116
+				 * @ORM\Column(name="updated_at", type="datetime", nullable=true)
117
+				 */
118
+				protected $updated_at;
119
+
120
+				/**
121
+				 * @ORM\ManyToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User")
122
+				 * @ORM\JoinColumn(name="updated_by", referencedColumnName="id", nullable=false)
123
+				 */
124
+				protected $updated_by;
125
+
126
+				/**
127
+				 * @return int
128
+				 */
129
+				public function getId()
130
+				{
131
+								return $this->id;
132
+				}
133
+
134
+				/**
135
+				 * @param int $id
136
+				 */
137
+				public function setId($id)
138
+				{
139
+								$this->id = $id;
140
+				}
141
+
142
+				/**
143
+				 * @return string
144
+				 */
145
+				public function getGuid()
146
+				{
147
+								return $this->guid;
148
+				}
149
+
150
+				/**
151
+				 * @param string $guid
152
+				 */
153
+				public function setGuid($guid)
154
+				{
155
+								$this->guid = $guid;
156
+				}
157 157
 	
158 158
 	/**
159 159
 	 * @return AccessRight
@@ -187,117 +187,117 @@  discard block
 block discarded – undo
187 187
 		$this->admin = $admin;
188 188
 	}
189 189
 
190
-    /**
191
-     * @return string
192
-     */
193
-    public function getFirstname()
194
-    {
195
-        return $this->firstname;
196
-    }
197
-
198
-    /**
199
-     * @param string $firstname
200
-     */
201
-    public function setFirstname($firstname)
202
-    {
203
-        $this->firstname = $firstname;
204
-    }
205
-
206
-    /**
207
-     * @return string
208
-     */
209
-    public function getLastname()
210
-    {
211
-        return $this->lastname;
212
-    }
213
-
214
-    /**
215
-     * @param string $lastname
216
-     */
217
-    public function setLastname($lastname)
218
-    {
219
-        $this->lastname = $lastname;
220
-    }
221
-
222
-    /**
223
-     * @return string
224
-     */
225
-    public function getAdress()
226
-    {
227
-        return $this->adress;
228
-    }
229
-
230
-    /**
231
-     * @param string $adress
232
-     */
233
-    public function setAdress($adress)
234
-    {
235
-        $this->adress = $adress;
236
-    }
237
-
238
-    /**
239
-     * @return string
240
-     */
241
-    public function getPostalCode()
242
-    {
243
-        return $this->postalCode;
244
-    }
245
-
246
-    /**
247
-     * @param string $postalCode
248
-     */
249
-    public function setPostalCode($postalCode)
250
-    {
251
-        $this->postalCode = $postalCode;
252
-    }
253
-
254
-    /**
255
-     * @return string
256
-     */
257
-    public function getCountry()
258
-    {
259
-        return $this->country;
260
-    }
261
-
262
-    /**
263
-     * @param string $country
264
-     */
265
-    public function setCountry($country)
266
-    {
267
-        $this->country = $country;
268
-    }
269
-
270
-    /**
271
-     * @return string
272
-     */
273
-    public function getState()
274
-    {
275
-        return $this->state;
276
-    }
277
-
278
-    /**
279
-     * @param string $state
280
-     */
281
-    public function setState($state)
282
-    {
283
-        $this->state = $state;
284
-    }
285
-
286
-    /**
287
-     * @return string
288
-     */
289
-    public function getAccessRights()
290
-    {
291
-        return $this->accessRights;
292
-    }
293
-
294
-    /**
295
-     * @param string $accessRights
296
-     */
297
-    public function setAccessRights($accessRights)
298
-    {
299
-        $this->accessRights = $accessRights;
300
-    }
190
+				/**
191
+				 * @return string
192
+				 */
193
+				public function getFirstname()
194
+				{
195
+								return $this->firstname;
196
+				}
197
+
198
+				/**
199
+				 * @param string $firstname
200
+				 */
201
+				public function setFirstname($firstname)
202
+				{
203
+								$this->firstname = $firstname;
204
+				}
205
+
206
+				/**
207
+				 * @return string
208
+				 */
209
+				public function getLastname()
210
+				{
211
+								return $this->lastname;
212
+				}
213
+
214
+				/**
215
+				 * @param string $lastname
216
+				 */
217
+				public function setLastname($lastname)
218
+				{
219
+								$this->lastname = $lastname;
220
+				}
221
+
222
+				/**
223
+				 * @return string
224
+				 */
225
+				public function getAdress()
226
+				{
227
+								return $this->adress;
228
+				}
229
+
230
+				/**
231
+				 * @param string $adress
232
+				 */
233
+				public function setAdress($adress)
234
+				{
235
+								$this->adress = $adress;
236
+				}
237
+
238
+				/**
239
+				 * @return string
240
+				 */
241
+				public function getPostalCode()
242
+				{
243
+								return $this->postalCode;
244
+				}
245
+
246
+				/**
247
+				 * @param string $postalCode
248
+				 */
249
+				public function setPostalCode($postalCode)
250
+				{
251
+								$this->postalCode = $postalCode;
252
+				}
253
+
254
+				/**
255
+				 * @return string
256
+				 */
257
+				public function getCountry()
258
+				{
259
+								return $this->country;
260
+				}
261
+
262
+				/**
263
+				 * @param string $country
264
+				 */
265
+				public function setCountry($country)
266
+				{
267
+								$this->country = $country;
268
+				}
269
+
270
+				/**
271
+				 * @return string
272
+				 */
273
+				public function getState()
274
+				{
275
+								return $this->state;
276
+				}
277
+
278
+				/**
279
+				 * @param string $state
280
+				 */
281
+				public function setState($state)
282
+				{
283
+								$this->state = $state;
284
+				}
285
+
286
+				/**
287
+				 * @return string
288
+				 */
289
+				public function getAccessRights()
290
+				{
291
+								return $this->accessRights;
292
+				}
293
+
294
+				/**
295
+				 * @param string $accessRights
296
+				 */
297
+				public function setAccessRights($accessRights)
298
+				{
299
+								$this->accessRights = $accessRights;
300
+				}
301 301
 	
302 302
 	/**
303 303
 	 * @return boolean
@@ -315,82 +315,82 @@  discard block
 block discarded – undo
315 315
 		$this->archived = $archived;
316 316
 	}
317 317
 
318
-    /**
319
-     * @return mixed
320
-     */
321
-    public function getCreatedAt()
322
-    {
323
-        return $this->created_at;
324
-    }
325
-
326
-    /**
327
-     * @param mixed $created_at
328
-     * @return User
329
-     */
330
-    public function setCreatedAt($created_at): User
331
-    {
332
-        $this->created_at = $created_at;
333
-
334
-        return $this;
335
-    }
336
-
337
-    /**
338
-     * @return mixed
339
-     */
340
-    public function getCreatedBy()
341
-    {
342
-        return $this->created_by;
343
-    }
344
-
345
-    /**
346
-     * @ORM\PrePersist
347
-     * @param mixed $created_by
348
-     * @return User
349
-     */
350
-    public function setCreatedBy($created_by): User
351
-    {
352
-        $this->created_by = $created_by;
353
-
354
-        return $this;
355
-    }
356
-
357
-    /**
358
-     * @return mixed
359
-     */
360
-    public function getUpdatedAt()
361
-    {
362
-        return $this->updated_at;
363
-    }
364
-
365
-    /**
366
-     * @param mixed $updated_at
367
-     * @return User
368
-     */
369
-    public function setUpdatedAt($updated_at): User
370
-    {
371
-        $this->updated_at = $updated_at;
372
-
373
-        return $this;
374
-    }
375
-
376
-    /**
377
-     * @return mixed
378
-     */
379
-    public function getUpdatedBy()
380
-    {
381
-        return $this->updated_by;
382
-    }
383
-
384
-    /**
385
-     * @ORM\PreUpdate
386
-     * @param mixed $updated_by
387
-     * @return User
388
-     */
389
-    public function setUpdatedBy($updated_by): User
390
-    {
391
-        $this->updated_by = $updated_by;
392
-
393
-        return $this;
394
-    }
318
+				/**
319
+				 * @return mixed
320
+				 */
321
+				public function getCreatedAt()
322
+				{
323
+								return $this->created_at;
324
+				}
325
+
326
+				/**
327
+				 * @param mixed $created_at
328
+				 * @return User
329
+				 */
330
+				public function setCreatedAt($created_at): User
331
+				{
332
+								$this->created_at = $created_at;
333
+
334
+								return $this;
335
+				}
336
+
337
+				/**
338
+				 * @return mixed
339
+				 */
340
+				public function getCreatedBy()
341
+				{
342
+								return $this->created_by;
343
+				}
344
+
345
+				/**
346
+				 * @ORM\PrePersist
347
+				 * @param mixed $created_by
348
+				 * @return User
349
+				 */
350
+				public function setCreatedBy($created_by): User
351
+				{
352
+								$this->created_by = $created_by;
353
+
354
+								return $this;
355
+				}
356
+
357
+				/**
358
+				 * @return mixed
359
+				 */
360
+				public function getUpdatedAt()
361
+				{
362
+								return $this->updated_at;
363
+				}
364
+
365
+				/**
366
+				 * @param mixed $updated_at
367
+				 * @return User
368
+				 */
369
+				public function setUpdatedAt($updated_at): User
370
+				{
371
+								$this->updated_at = $updated_at;
372
+
373
+								return $this;
374
+				}
375
+
376
+				/**
377
+				 * @return mixed
378
+				 */
379
+				public function getUpdatedBy()
380
+				{
381
+								return $this->updated_by;
382
+				}
383
+
384
+				/**
385
+				 * @ORM\PreUpdate
386
+				 * @param mixed $updated_by
387
+				 * @return User
388
+				 */
389
+				public function setUpdatedBy($updated_by): User
390
+				{
391
+								$this->updated_by = $updated_by;
392
+
393
+								return $this;
394
+				}
395 395
 }
396 396
 
Please login to merge, or discard this patch.