How to make web form access for only particular roles

I made a web form and I was able to check if the user has permission for the doctype on which web form is based on

frappe.ready(function() {
	// // bind events here
	frappe.has_permission("doctype_name", "", "create")
		.then((res)=>{ 
			console.log("has_perm: ",res.message.has_permission)
			if(res.message.has_permission != true){
				frappe.throw("You can't Access this Form");
				return false;
			}
		})	
})

now if res.message.has_permission != true then user should be
unable to open the web form or simply they should be unable to access the web form or when saved then it should say unable to access the web form and should not be saved
so i tried using “return false;” but no use how can I do it

Try this to hide Web Form

frappe.has_permission("Doctype Name", "", "create")
		.then((res)=>{ 
			console.log(res);
			if(!res.has_permission){
				$(".success-title").text(__("Error"));
				$("svg.success-icon.icon").hide();
				$(".success-footer").hide();
				$(".success-message").text(__("You can't Access this Form"));
				$(".web-form-container").hide();
				$(".success-page").removeClass("hide");
			}
	})