@@ -368,6 +368,40 @@ component singleton accessors="true" {
368
368
return this ;
369
369
}
370
370
371
+ /**
372
+ * This is the method proxy injected into the request context that will act like the
373
+ * `secureView()` method velow
374
+ *
375
+ * @permissions One, a list or an array of permissions
376
+ * @successView The view to set in the request context if the permissions pass
377
+ * @failView The view to set in the request context if the permissions fails, optional
378
+ */
379
+ function secureViewProxy ( required permissions , required successView , failView ){
380
+ arguments .event = this ;
381
+ controller
382
+ .getWireBox ()
383
+ .getInstance ( dsl = " @cbSecurity" )
384
+ .secureView ( argumentCollection = arguments );
385
+ return this ;
386
+ }
387
+
388
+ /**
389
+ * This method is injected into all request contex's in order to allow you to easily
390
+ * switch between views if the permissions are not found in the user.
391
+ *
392
+ * @event The proxied request context
393
+ * @permissions One, a list or an array of permissions
394
+ * @successView The view to set in the request context if the permissions pass
395
+ * @failView The view to set in the request context if the permissions fails, optional
396
+ */
397
+ function secureView ( required event , required permissions , required successView , failView ){
398
+ if ( has ( arguments .permissions ) ){
399
+ arguments .event .setView ( arguments .successView );
400
+ } else if ( ! isNull ( arguments .failView ) ){
401
+ arguments .event .setView ( arguments .failView );
402
+ }
403
+ }
404
+
371
405
/* **************************************************************/
372
406
/* Private Methods
373
407
/***************************************************************/
0 commit comments