Skip to content

Commit dc4ac4a

Browse files
authored
Merge pull request #24 from michaelborn/patch/default-validator-auth-service
Patch/default validator auth service
2 parents 942e92b + 3c77e2b commit dc4ac4a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

models/validators/CBAuthValidator.cfc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
component singleton {
99

1010
// Injection
11-
property name="cbauth" inject="authenticationService@cbauth";
11+
property name="cbSecurity" inject="CBSecurity@cbSecurity";
1212

1313
/**
1414
* This function is called once an incoming event matches a security rule.
@@ -54,10 +54,10 @@ component singleton {
5454
};
5555

5656
// Are we logged in?
57-
if ( variables.cbauth.isLoggedIn() ) {
57+
if ( variables.cbSecurity.getAuthService().isLoggedIn() ) {
5858
// Do we have any permissions?
5959
if ( listLen( arguments.permissions ) ) {
60-
results.allow = variables.cbauth.getUser().hasPermission( arguments.permissions );
60+
results.allow = variables.cbSecurity.getAuthService().getUser().hasPermission( arguments.permissions );
6161
results.type = "authorization";
6262
} else {
6363
// We are satisfied!

test-harness/tests/specs/unit/SecurityTest.cfc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
1818
.$( "getAppRootPath", expandPath( "/root" ) )
1919
.$( "getColdboxSettings", {
2020
"version": "6.0.0"
21-
}, false );
21+
}, false );
22+
23+
mockController
24+
.$( "getSetting" )
25+
.$args( "modules" )
26+
.$results( [] );
27+
2228
security = interceptor;
2329
security.setInvalidEventHandler( '' );
2430
settings = {
@@ -114,7 +120,8 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
114120
.$args( settings.validator )
115121
.$results( wirebox.getInstance( settings.validator ) );
116122

117-
security.configure();
123+
security.afterAspectsLoad();
124+
118125
expect(
119126
security.getValidator(
120127
createMock( "coldbox.system.web.context.RequestContext" ).$( "getCurrentModule", "" )
@@ -135,7 +142,7 @@ component extends="coldbox.system.testing.BaseInterceptorTest" interceptor="cbse
135142
.$results( createStub() );
136143

137144
expect( function(){
138-
security.configure();
145+
security.afterAspectsLoad();
139146
} ).toThrow( "Security.ValidatorMethodException" );
140147
} );
141148

0 commit comments

Comments
 (0)