Skip to content

Commit 11a6532

Browse files
committed
finalized formatting
1 parent bc3ad99 commit 11a6532

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

models/CBSecurity.cfc

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ component singleton accessors="true" {
2222
/** DI **/
2323
/*********************************************************************************************/
2424

25-
property name="settings" inject="coldbox:moduleSettings:cbsecurity";
26-
property name="log" inject="logbox:logger:{this}";
27-
property name="wirebox" inject="wirebox";
25+
property name="settings" inject="coldbox:moduleSettings:cbsecurity";
26+
property name="log" inject="logbox:logger:{this}";
27+
property name="wirebox" inject="wirebox";
2828

2929

3030
/*********************************************************************************************/
@@ -120,7 +120,8 @@ component singleton accessors="true" {
120120
return arrayWrap( arguments.permissions )
121121
.filter( function( item ){
122122
return oUser.hasPermission( arguments.item );
123-
} ).len() > 0;
123+
} )
124+
.len() > 0;
124125
}
125126

126127
/**
@@ -131,13 +132,14 @@ component singleton accessors="true" {
131132
* @permissions One, a list or an array of permissions
132133
*/
133134
boolean function all( required permissions ){
134-
var oUser = getAuthService().getUser();
135-
var aPerms = arrayWrap( arguments.permissions );
135+
var oUser = getAuthService().getUser();
136+
var aPerms = arrayWrap( arguments.permissions );
136137

137138
return aPerms
138139
.filter( function( item ){
139140
return oUser.hasPermission( arguments.item );
140-
} ).len() == aPerms.len();
141+
} )
142+
.len() == aPerms.len();
141143
}
142144

143145
/**
@@ -153,7 +155,8 @@ component singleton accessors="true" {
153155
return arrayWrap( arguments.permissions )
154156
.filter( function( item ){
155157
return oUser.hasPermission( arguments.item );
156-
} ).len() == 0;
158+
} )
159+
.len() == 0;
157160
}
158161

159162
/**
@@ -182,9 +185,9 @@ component singleton accessors="true" {
182185
*
183186
* @returns CBSecurity
184187
*/
185-
CBSecurity function secure( required permissions, message=variables.DEFAULT_ERROR_MESSAGE ){
186-
if( !has( arguments.permissions ) ){
187-
throw( type = "NotAuthorized", message=arguments.message );
188+
CBSecurity function secure( required permissions, message = variables.DEFAULT_ERROR_MESSAGE ){
189+
if ( !has( arguments.permissions ) ) {
190+
throw( type = "NotAuthorized", message = arguments.message );
188191
}
189192
return this;
190193
}
@@ -199,9 +202,9 @@ component singleton accessors="true" {
199202
*
200203
* @returns CBSecurity
201204
*/
202-
CBSecurity function secureAll( required permissions, message=variables.DEFAULT_ERROR_MESSAGE ){
203-
if( !all( arguments.permissions ) ){
204-
throw( type = "NotAuthorized", message=arguments.message );
205+
CBSecurity function secureAll( required permissions, message = variables.DEFAULT_ERROR_MESSAGE ){
206+
if ( !all( arguments.permissions ) ) {
207+
throw( type = "NotAuthorized", message = arguments.message );
205208
}
206209
return this;
207210
}
@@ -216,9 +219,9 @@ component singleton accessors="true" {
216219
*
217220
* @returns CBSecurity
218221
*/
219-
CBSecurity function secureNone( required permissions, message=variables.DEFAULT_ERROR_MESSAGE ){
220-
if( !none( arguments.permissions ) ){
221-
throw( type = "NotAuthorized", message=arguments.message );
222+
CBSecurity function secureNone( required permissions, message = variables.DEFAULT_ERROR_MESSAGE ){
223+
if ( !none( arguments.permissions ) ) {
224+
throw( type = "NotAuthorized", message = arguments.message );
222225
}
223226
return this;
224227
}
@@ -243,13 +246,13 @@ component singleton accessors="true" {
243246
*
244247
* @returns CBSecurity
245248
*/
246-
CBSecurity function secureWhen( required context, message=variables.DEFAULT_ERROR_MESSAGE ){
249+
CBSecurity function secureWhen( required context, message = variables.DEFAULT_ERROR_MESSAGE ){
247250
var results = arguments.context;
248251
// Check if udf/lambda
249-
if( isCustomFunction( arguments.context ) || isClosure( arguments.context ) ){
252+
if ( isCustomFunction( arguments.context ) || isClosure( arguments.context ) ) {
250253
results = arguments.context( getAuthService().getUser() );
251254
}
252-
if( results ){
255+
if ( results ) {
253256
throw( type = "NotAuthorized", message = arguments.message );
254257
}
255258
return this;
@@ -259,7 +262,7 @@ component singleton accessors="true" {
259262
* Alias proxy if somebody is coming from cbguard, proxies to the secure() method
260263
*/
261264
function guard(){
262-
return secure( argumentCollection=arguments );
265+
return secure( argumentCollection = arguments );
263266
}
264267

265268
/***************************************************************/
@@ -285,11 +288,15 @@ component singleton accessors="true" {
285288
* @success The closure/lambda/udf that executes if the context passes
286289
* @fail The closure/lambda/udf that executes if the context fails
287290
*/
288-
function when( required permissions, required success, fail ){
291+
function when(
292+
required permissions,
293+
required success,
294+
fail
295+
){
289296
arguments.permissions = arrayWrap( arguments.permissions );
290-
if( has( arguments.permissions ) ){
297+
if ( has( arguments.permissions ) ) {
291298
arguments.success( getAuthService().getUser(), arguments.permissions );
292-
} else if( !isNull( arguments.fail ) ){
299+
} else if ( !isNull( arguments.fail ) ) {
293300
arguments.fail( getAuthService().getUser(), arguments.permissions );
294301
}
295302
return this;
@@ -314,11 +321,15 @@ component singleton accessors="true" {
314321
* @success The closure/lambda/udf that executes if the context passes
315322
* @fail The closure/lambda/udf that executes if the context fails
316323
*/
317-
function whenAll( required permissions, required success, fail ){
324+
function whenAll(
325+
required permissions,
326+
required success,
327+
fail
328+
){
318329
arguments.permissions = arrayWrap( arguments.permissions );
319-
if( all( arguments.permissions ) ){
330+
if ( all( arguments.permissions ) ) {
320331
arguments.success( getAuthService().getUser(), arguments.permissions );
321-
} else if( !isNull( arguments.fail ) ){
332+
} else if ( !isNull( arguments.fail ) ) {
322333
arguments.fail( getAuthService().getUser(), arguments.permissions );
323334
}
324335
return this;
@@ -343,11 +354,15 @@ component singleton accessors="true" {
343354
* @success The closure/lambda/udf that executes if the context passes
344355
* @fail The closure/lambda/udf that executes if the context fails
345356
*/
346-
function whenNone( required permissions, required success, fail ){
357+
function whenNone(
358+
required permissions,
359+
required success,
360+
fail
361+
){
347362
arguments.permissions = arrayWrap( arguments.permissions );
348-
if( none( arguments.permissions ) ){
363+
if ( none( arguments.permissions ) ) {
349364
arguments.success( getAuthService().getUser(), arguments.permissions );
350-
} else if( !isNull( arguments.fail ) ){
365+
} else if ( !isNull( arguments.fail ) ) {
351366
arguments.fail( getAuthService().getUser(), arguments.permissions );
352367
}
353368
return this;
@@ -366,4 +381,4 @@ component singleton accessors="true" {
366381
return isArray( arguments.items ) ? items : items.listToArray();
367382
}
368383

369-
}
384+
}

models/jwt/JwtService.cfc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ component accessors="true" singleton {
1717
property name="interceptorService" inject="coldbox:interceptorService";
1818
property name="requestService" inject="coldbox:requestService";
1919
property name="log" inject="logbox:logger:{this}";
20-
property name="cbsecurity" inject="@cbSecurity";
20+
property name="cbsecurity" inject="@cbSecurity";
2121

2222
/*********************************************************************************************/
2323
/** PROPERTIES **/
@@ -244,7 +244,9 @@ component accessors="true" singleton {
244244
*/
245245
function authenticate(){
246246
// Get the User it represents
247-
var oUser = variables.cbSecurity.getUserService().retrieveUserById( getPayload().sub );
247+
var oUser = variables.cbSecurity
248+
.getUserService()
249+
.retrieveUserById( getPayload().sub );
248250

249251
// Verify it
250252
if ( isNull( oUser ) || !len( oUser.getId() ) ) {
@@ -715,7 +717,10 @@ component accessors="true" singleton {
715717
results.allow = (
716718
tokenHasScopes( arguments.permissions, payload.scopes )
717719
||
718-
variables.cbSecurity.getAuthService().getUser().hasPermission( arguments.permissions )
720+
variables.cbSecurity
721+
.getAuthService()
722+
.getUser()
723+
.hasPermission( arguments.permissions )
719724
);
720725
results.type = "authorization";
721726
} else {

0 commit comments

Comments
 (0)