Auth js refactor