split a bit more the code from auth.js

- the integration test does not work