Finalized code for registration and login flow.