Make $login return a promise, fixes #175