Refactor for the wechat auth logic and added checking on the state parameter for the appid.