Adding working custom authentication (needs refactoring)