See the Description

I've made some improvements. Now seems there are problems in
attemptLogin(), your "res" returned "Failed". Please check the function
and repair it.