@@ -58,23 +58,23 @@ |
||
58 | 58 | throw new UnexpectedValueException($value, 'string'); |
59 | 59 | } |
60 | 60 | |
61 | - if(!ctype_digit($value)) { |
|
61 | + if (!ctype_digit($value)) { |
|
62 | 62 | $this->context->addViolation('validator.google_code.only_digits_allowed'); |
63 | 63 | } |
64 | 64 | |
65 | 65 | //Number must have 6 digits |
66 | - if(strlen($value) !== 6) { |
|
66 | + if (strlen($value) !== 6) { |
|
67 | 67 | $this->context->addViolation('validator.google_code.wrong_digit_count'); |
68 | 68 | } |
69 | 69 | |
70 | 70 | //Try to retrieve the user we want to check |
71 | - if($this->context->getObject() instanceof FormInterface && |
|
71 | + if ($this->context->getObject() instanceof FormInterface && |
|
72 | 72 | $this->context->getObject()->getParent() instanceof FormInterface |
73 | 73 | && $this->context->getObject()->getParent()->getData() instanceof User) { |
74 | 74 | $user = $this->context->getObject()->getParent()->getData(); |
75 | 75 | |
76 | 76 | //Check if the given code is valid |
77 | - if(!$this->googleAuthenticator->checkCode($user, $value)) { |
|
77 | + if (!$this->googleAuthenticator->checkCode($user, $value)) { |
|
78 | 78 | $this->context->addViolation('validator.google_code.wrong_code'); |
79 | 79 | } |
80 | 80 |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | $user = $this->security->getUser(); |
77 | 77 | $request = $event->getRequest(); |
78 | 78 | |
79 | - if(!$event->isMasterRequest()) { |
|
79 | + if (!$event->isMasterRequest()) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | - if(!$user instanceof User) { |
|
82 | + if (!$user instanceof User) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | |
99 | 99 | /* Dont redirect tree endpoints, as this would cause trouble and creates multiple flash |
100 | 100 | warnigs for one page reload */ |
101 | - if(strpos($request->getUri(), '/tree/') !== false) { |
|
101 | + if (strpos($request->getUri(), '/tree/') !== false) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | //Show appropriate message to user about the reason he was redirected |
106 | - if($user->isNeedPwChange()) { |
|
106 | + if ($user->isNeedPwChange()) { |
|
107 | 107 | $this->flashBag->add('warning', 'user.pw_change_needed.flash'); |
108 | 108 | } |
109 | 109 | |
110 | - if(static::TFARedirectNeeded($user)) { |
|
110 | + if (static::TFARedirectNeeded($user)) { |
|
111 | 111 | $this->flashBag->add('warning', 'user.2fa_needed.flash'); |
112 | 112 | } |
113 | 113 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function enableBackupCodes(User $user) |
46 | 46 | { |
47 | - if(empty($user->getBackupCodes())) { |
|
47 | + if (empty($user->getBackupCodes())) { |
|
48 | 48 | $this->regenerateBackupCodes($user); |
49 | 49 | } |
50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function disableBackupCodesIfUnused(User $user) |
57 | 57 | { |
58 | - if($user->isGoogleAuthenticatorEnabled()) { |
|
58 | + if ($user->isGoogleAuthenticatorEnabled()) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | public function generateCodeSet() : array |
69 | 69 | { |
70 | 70 | $array = []; |
71 | - for($n=0; $n<$this->code_count; $n++) { |
|
71 | + for ($n = 0; $n < $this->code_count; $n++) { |
|
72 | 72 | $array[] = $this->generateSingleCode(); |
73 | 73 | } |
74 | 74 |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | public function invalidateBackupCode(string $code): void |
755 | 755 | { |
756 | 756 | $key = array_search($code, $this->backupCodes); |
757 | - if ($key !== false){ |
|
757 | + if ($key !== false) { |
|
758 | 758 | unset($this->backupCodes[$key]); |
759 | 759 | } |
760 | 760 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | public function setBackupCodes(array $codes) : self |
777 | 777 | { |
778 | 778 | $this->backupCodes = $codes; |
779 | - if(empty($codes)) { |
|
779 | + if (empty($codes)) { |
|
780 | 780 | $this->backupCodesGenerationDate = null; |
781 | 781 | } else { |
782 | 782 | $this->backupCodesGenerationDate = new \DateTime(); |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | public function getPreferredTwoFactorProvider(): ?string |
854 | 854 | { |
855 | 855 | //If U2F is available then prefer it |
856 | - if($this->isU2FAuthEnabled()) { |
|
856 | + if ($this->isU2FAuthEnabled()) { |
|
857 | 857 | return 'u2f_two_factor'; |
858 | 858 | } |
859 | 859 |
@@ -82,7 +82,7 @@ |
||
82 | 82 | //$result = iterator_to_array($recursiveIterator); |
83 | 83 | |
84 | 84 | //We can not use iterator_to_array here or we get only the parent elements |
85 | - foreach($recursiveIterator as $item) { |
|
85 | + foreach ($recursiveIterator as $item) { |
|
86 | 86 | $result[] = $item; |
87 | 87 | } |
88 | 88 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | protected $cache; |
43 | 43 | protected $keyGenerator; |
44 | 44 | |
45 | - public function __construct( EntityManagerInterface $em, TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator) |
|
45 | + public function __construct(EntityManagerInterface $em, TagAwareCacheInterface $treeCache, UserCacheKeyGenerator $keyGenerator) |
|
46 | 46 | { |
47 | 47 | $this->em = $em; |
48 | 48 | $this->keyGenerator = $keyGenerator; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $secure_class_name = str_replace('\\', '_', $class_name); |
66 | 66 | $key = 'list_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.$parent_id; |
67 | 67 | |
68 | - $ret = $this->cache->get($key, function (ItemInterface $item) use ($class_name, $parent, $secure_class_name) { |
|
68 | + $ret = $this->cache->get($key, function(ItemInterface $item) use ($class_name, $parent, $secure_class_name) { |
|
69 | 69 | // Invalidate when groups, a element with the class or the user changes |
70 | 70 | $item->tag(['groups', 'tree_list', $this->keyGenerator->generateKey(), $secure_class_name]); |
71 | 71 | /** |
@@ -77,7 +77,7 @@ |
||
77 | 77 | { |
78 | 78 | $key = 'tree_tools_'.$this->keyGenerator->generateKey(); |
79 | 79 | |
80 | - return $this->cache->get($key, function (ItemInterface $item) { |
|
80 | + return $this->cache->get($key, function(ItemInterface $item) { |
|
81 | 81 | //Invalidate tree, whenever group or the user changes |
82 | 82 | $item->tag(['tree_tools', 'groups', $this->keyGenerator->generateKey()]); |
83 | 83 |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getGenericTree(string $class, ?StructuralDBElement $parent = null) : array |
119 | 119 | { |
120 | - if(!is_a($class, NamedDBElement::class, true)) { |
|
120 | + if (!is_a($class, NamedDBElement::class, true)) { |
|
121 | 121 | throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!'); |
122 | 122 | } |
123 | - if($parent !== null && !is_a($parent, $class)) { |
|
123 | + if ($parent !== null && !is_a($parent, $class)) { |
|
124 | 124 | throw new \InvalidArgumentException('$parent must be of the type $class!'); |
125 | 125 | } |
126 | 126 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $secure_class_name = str_replace('\\', '_', $class); |
136 | 136 | $key = 'treeview_'.$this->keyGenerator->generateKey().'_'.$secure_class_name; |
137 | 137 | |
138 | - $ret = $this->cache->get($key, function (ItemInterface $item) use ($repo, $parent, $secure_class_name) { |
|
138 | + $ret = $this->cache->get($key, function(ItemInterface $item) use ($repo, $parent, $secure_class_name) { |
|
139 | 139 | // Invalidate when groups, a element with the class or the user changes |
140 | 140 | $item->tag(['groups', 'tree_treeview', $this->keyGenerator->generateKey(), $secure_class_name]); |
141 | 141 | return $repo->getGenericNodeTree($parent); |