improve for log in and out handler

login and logout now returns a serialized json object