File tree Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ component {
47
47
// The debugger will still track requests even in non debug mode.
48
48
debugMode : controller .getSetting ( name = " environment" , defaultValue = " production" ) == " development" ,
49
49
// The URL password to use to activate it on demand
50
+ // if set to cb:null, will generate random password
51
+ // to enable debugger in dev environment set to empty or custom password
52
+ // in live environment leave cb:null or set your own password
50
53
debugPassword : " cb:null" ,
51
54
// This flag enables/disables the end of request debugger panel docked to the bottem of the page.
52
55
// If you disable i, then the only way to visualize the debugger is via the `/cbdebugger` endpoint
Original file line number Diff line number Diff line change @@ -30,11 +30,21 @@ component extends="coldbox.system.RestHandler" {
30
30
* Debugger disabled event
31
31
*/
32
32
function disabled ( event , rc , prc ){
33
+ var data = " Page Not Found" ;
34
+
35
+ if ( getSetting (" environment" ) == " DEVELOPMENT" ){
36
+ data = ' isDebugCookieValid defined: ' & debuggerService .isDebugCookieValid () ;
37
+ data & = ' , secretKey defined: ' & debuggerService .isSecretKeyDefined () ;
38
+ data & = ' , doesCookieMatchesSecretKey: ' & debuggerService .doesCookieMatchesSecretKey () ;
39
+
40
+ data & = ' , debugMode: ' & debuggerService .getDebugMode ();
41
+ }
42
+
33
43
event .renderData (
34
44
statusCode = 404 ,
35
45
statusText = " Not Found" ,
36
46
type = " text" ,
37
- data = " Page Not Found "
47
+ data = data
38
48
);
39
49
}
40
50
Original file line number Diff line number Diff line change @@ -146,22 +146,33 @@ component
146
146
*/
147
147
boolean function getDebugMode (){
148
148
// If no secretKey has been set, don't allow debug mode
149
- if ( not ( len ( variables . secretKey ) ) ) {
149
+ if ( not ( isSecretKeyDefined ( ) ) ) {
150
150
return false ;
151
151
}
152
152
// If Cookie exists, it's value is used.
153
153
if ( isDebugCookieValid () ) {
154
154
// Must be equal to the current secret key
155
- if ( cookie [ variables .cookieName ] == variables .secretKey ) {
156
- return true ;
157
- } else {
158
- return false ;
159
- }
155
+ return doesCookieMatchesSecretKey ()
160
156
}
161
157
162
158
// If there is no cookie, then use default to app setting
163
159
return variables .debugMode ;
164
160
}
161
+
162
+ /**
163
+ * returns boolean if secret key is defined
164
+ * init() will set secret key
165
+ */
166
+ boolean function isSecretKeyDefined (){
167
+ return javacast (' Boolean' ,len ( variables .secretKey ));
168
+ }
169
+
170
+ /**
171
+ * checks if cookie matches secret key
172
+ */
173
+ boolean function doesCookieMatchesSecretKey (){
174
+ return cookie [ variables .cookieName ] == variables .secretKey ;
175
+ }
165
176
166
177
/**
167
178
* Checks if the debug cookie is a valid cookie. Boolean
You can’t perform that action at this time.
0 commit comments