Login implementation. Http api is dirty yet (next step is to generify it a bit)