nolanerck
09/14/2022, 5:14 PMtry
{
var userObj = AuthService.authenticate(username=rc.email, password=EncryptionService.hashPassword(rc.password));
}
catch( ex )
{
if( ex.type eq "InvalidCredentials" )
{
relocate( event="auth/onInvalidLogin", persistStruct={ errMsg: "something bad happened!" } );
}
}
...but that seems like the long way around the problem. Trying to figure out why our "invalidAuthenticationEvent' isn't firing off. Suggestions welcome. Thanks.Patrick
09/14/2022, 5:49 PMex
is outputting in your catch OR remove your If logic in your catch to see if it passes through and triggers the invalidAuthenticationEvent by default.wil-shiftinsert
09/14/2022, 5:50 PMdologin
action has no cbsecurity protection (otherwise you can not even access it), and on executing your authenticate call the cbauth authenticationservice will call getUserService().isValidCredentials and if this is false it will throw the InvalidCredentials exception.nolanerck
09/14/2022, 5:53 PMwil-shiftinsert
09/14/2022, 5:53 PMwil-shiftinsert
09/14/2022, 5:53 PMwil-shiftinsert
09/14/2022, 5:55 PMwil-shiftinsert
09/14/2022, 5:56 PMwil-shiftinsert
09/14/2022, 5:57 PMnolanerck
09/14/2022, 5:57 PMwil-shiftinsert
09/14/2022, 6:00 PMwil-shiftinsert
09/14/2022, 6:00 PMwil-shiftinsert
09/14/2022, 6:01 PMwil-shiftinsert
09/14/2022, 6:04 PMwil-shiftinsert
09/14/2022, 6:07 PMnolanerck
09/14/2022, 6:08 PMwil-shiftinsert
09/14/2022, 6:11 PMPatrick
09/14/2022, 6:13 PM// The global invalid authentication event or URI or URL to go if an invalid authentication occurs
is what invalidAuthenticationEvent
is commented. To me that means if you do NOT try to catch anything then it fires that event.wil-shiftinsert
09/14/2022, 6:13 PMPatrick
09/14/2022, 6:16 PMwil-shiftinsert
09/14/2022, 6:16 PMwil-shiftinsert
09/14/2022, 6:17 PMwil-shiftinsert
09/14/2022, 6:17 PMwil-shiftinsert
09/14/2022, 6:19 PMwil-shiftinsert
09/14/2022, 6:20 PMwil-shiftinsert
09/14/2022, 6:20 PMnolanerck
09/14/2022, 6:22 PMPatrick
09/14/2022, 6:24 PMnolanerck
09/14/2022, 6:24 PMnolanerck
09/14/2022, 6:25 PMPatrick
09/14/2022, 6:25 PMnolanerck
09/14/2022, 6:25 PMwil-shiftinsert
09/14/2022, 6:25 PMnolanerck
09/14/2022, 6:26 PMwil-shiftinsert
09/14/2022, 6:28 PMwil-shiftinsert
09/14/2022, 6:29 PMnolanerck
09/14/2022, 6:31 PMwil-shiftinsert
09/14/2022, 6:32 PMwil-shiftinsert
09/14/2022, 6:34 PMnolanerck
09/14/2022, 6:34 PMwil-shiftinsert
09/14/2022, 6:36 PMwil-shiftinsert
09/14/2022, 6:37 PMwil-shiftinsert
09/14/2022, 6:38 PMnolanerck
09/14/2022, 6:40 PMPatrick
09/14/2022, 6:41 PMnolanerck
09/14/2022, 6:42 PMwil-shiftinsert
09/14/2022, 6:42 PMif ( !getUserService().isValidCredentials( arguments.username, arguments.password ) ) {
variables.interceptorService.processState(
"onInvalidCredentials",
{
"username" : arguments.username,
"password" : arguments.password
}
);
throw( type = "InvalidCredentials", message = "Incorrect Credentials Entered" );
}
if you would prepend this with this line, I think you would have your desired workflow:
if ( !getUserService().isValidCredentials( arguments.username, arguments.password ) ) return;
the only thing is that you don’t return a valid authenticated user here. But that makes sense if your credentials are in codewil-shiftinsert
09/14/2022, 6:44 PMwil-shiftinsert
09/14/2022, 6:46 PMwil-shiftinsert
09/14/2022, 6:47 PMwil-shiftinsert
09/14/2022, 6:49 PMPatrick
09/14/2022, 6:51 PMwil-shiftinsert
09/14/2022, 6:52 PMwil-shiftinsert
09/14/2022, 6:52 PMnolanerck
09/14/2022, 6:57 PMnolanerck
09/14/2022, 6:58 PMwil-shiftinsert
09/14/2022, 7:04 PM