@@ -106,37 +106,29 @@ public function startup(Event $event)
106
106
$ this ->_action = $ this ->request ->params ['action ' ];
107
107
try {
108
108
$ this ->_secureRequired ($ controller );
109
- } catch (SecurityException $ se ) {
110
- $ this ->blackHole ($ controller , $ se ->getType (), $ se );
111
- }
112
- try {
113
109
$ this ->_authRequired ($ controller );
114
- } catch (AuthSecurityException $ ase ) {
115
- $ this ->blackHole ($ controller , $ ase ->getType (), $ ase );
116
- }
117
-
118
110
119
- $ hasData = !empty ($ this ->request ->data );
120
- $ isNotRequestAction = (
121
- !isset ($ controller ->request ->params ['requested ' ]) ||
122
- $ controller ->request ->params ['requested ' ] != 1
123
- );
111
+ $ hasData = !empty ($ this ->request ->data );
112
+ $ isNotRequestAction = (
113
+ !isset ($ controller ->request ->params ['requested ' ]) ||
114
+ $ controller ->request ->params ['requested ' ] != 1
115
+ );
124
116
125
- if ($ this ->_action === $ this ->_config ['blackHoleCallback ' ]) {
126
- return $ this ->blackHole ( $ controller , ' auth ' );
127
- }
117
+ if ($ this ->_action === $ this ->_config ['blackHoleCallback ' ]) {
118
+ throw new AuthSecurityException ( sprintf ( ' Action %s is defined as the blackhole callback. ' , $ this ->_action ) );
119
+ }
128
120
129
- if (!in_array ($ this ->_action , (array )$ this ->_config ['unlockedActions ' ]) &&
130
- $ hasData && $ isNotRequestAction
131
- ) {
132
- if ($ this ->_config ['validatePost ' ]) {
133
- try {
121
+ if (!in_array ($ this ->_action , (array )$ this ->_config ['unlockedActions ' ]) &&
122
+ $ hasData && $ isNotRequestAction
123
+ ) {
124
+ if ($ this ->_config ['validatePost ' ]) {
134
125
$ this ->_validatePost ($ controller );
135
- } catch (SecurityException $ se ) {
136
- return $ this ->blackHole ($ controller , $ se ->getType (), $ se );
137
126
}
138
127
}
128
+ } catch (SecurityException $ se ) {
129
+ $ this ->blackHole ($ controller , $ se ->getType (), $ se );
139
130
}
131
+
140
132
$ this ->generateToken ($ controller ->request );
141
133
if ($ hasData && is_array ($ controller ->request ->data )) {
142
134
unset($ controller ->request ->data ['_Token ' ]);
@@ -188,6 +180,7 @@ public function requireAuth($actions)
188
180
*
189
181
* @param \Cake\Controller\Controller $controller Instantiating controller
190
182
* @param string $error Error method
183
+ * @param SecurityException $exception thrown by validate methods, passed only in debug mode
191
184
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
192
185
* @see SecurityComponent::$blackHoleCallback
193
186
* @link http://book.cakephp.org/3.0/en/controllers/components/security.html#handling-blackhole-callbacks
0 commit comments