Reading the notes on the link you provided, it sounds like things changed with custom authentication in 2017 in that it no longer relies on the ASP.NET stuff and now relies on IRSRequestContext. I imagine that would require a pretty good rewrite/refactor of how you did it in 2014.
My guess on what you are doing is taking the 2014 code you have and trying to modify it to work with 2019. If so, there isn't much anyone here can do to help without seeing all of your code. Since you are getting a null object exception, you will need to do some digging to determine what object is null at that point in the application, and address it appropriately. MAYBE it is expected to be null and you just need to handle it better (try/catch block), or maybe it shouldn't be null and you need to check for that before doing any operations on it and handle the null scenario first.
That being said, I have never set up custom authentication before - I always use AD authentication. I've not found a need for any other forms of authentication. BUT I have done C# development and am aware of what a null object exception is and what causes it - you are performing an operation on an object that is null.
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.