Check if page has password before showing custom post type singular pages

Hey there :slight_smile:

I have created a page with a password. Once, the user, enter that password, that page and all posts with post-type "events" will be available. However, if the password has not been added then they will simply redirect to the front page.
I assume the logic will be something like:
if( password_for_page ( ID ) || is post_type( 'events' ) ) {
// do something
} else {
wp_redirect( home_url() );
I am just not quite sure if there is a function that programmatically will allow me to check if a password has been set for a certain page and then allow me to block the singular pages for post type ( 'events ), if it has not been added.