@@ 90-107 (lines=18) @@ | ||
87 | * @param bool $strict |
|
88 | * @return bool |
|
89 | */ |
|
90 | public function authorizeAny(array $permissions, UserInterface $user = null, $strict = false) |
|
91 | { |
|
92 | if (!$user) { |
|
93 | $user = $this->guard->user(); |
|
94 | } |
|
95 | ||
96 | if (!$user) { |
|
97 | return !$strict; |
|
98 | } |
|
99 | ||
100 | foreach ($permissions as $permission) { |
|
101 | if ($this->checkPermission($permission, $user)) { |
|
102 | return true; |
|
103 | } |
|
104 | } |
|
105 | ||
106 | return false; |
|
107 | } |
|
108 | ||
109 | /** |
|
110 | * Authorize a user against all permission. |
|
@@ 117-134 (lines=18) @@ | ||
114 | * @param bool $strict |
|
115 | * @return bool |
|
116 | */ |
|
117 | public function authorizeAll(array $permissions, UserInterface $user = null, $strict = false) |
|
118 | { |
|
119 | if (!$user) { |
|
120 | $user = $this->guard->user(); |
|
121 | } |
|
122 | ||
123 | if (!$user) { |
|
124 | return !$strict; |
|
125 | } |
|
126 | ||
127 | foreach ($permissions as $permission) { |
|
128 | if (!$this->checkPermission($permission, $user)) { |
|
129 | return false; |
|
130 | } |
|
131 | } |
|
132 | ||
133 | return true; |
|
134 | } |
|
135 | ||
136 | /** |
|
137 | * Return a user's permission. |