Refactor login logic to the login widget.

**DO NOT MERGE**

A little work needs to be done yet.
the object seems ok, but why do you need a sync interface?
afaik we do async in the frontend too. you just need a proxy object where to pass callbacks.
have in mind that, when the porting is done, there will pure async in the backend, and no more ops in the frontend.