Skip to content

userBean not defined if logged-in user is not found #20

@michaelborn

Description

@michaelborn

AuthenticationService's getUser() method should be able to handle a null response from the user service.

https://github.com/coldbox-modules/cbauth/blob/main/models/AuthenticationService.cfc#L152-L163 - it seems getUser() expects getUserService().retrieveUserById(...) to throw an error if the user cannot be found.

Instead, I'd prefer to handle null's as a missing user, and logout or clear the session val.

The context of this is that a logged-in user was deleted. (don't ask!)

I would be happy to PR something like this toAuthenticationService.cfc's getUser() method:

if ( isNull( userBean ) ){
    variables.sessionStorage.delete( variables.USER_ID_KEY );
    throw( "User not found" );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions