Attempted implementation of loginUser, not working correctly