Refactored local authentication fully working