{"action":"created","issue":{"url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/10","repository_url":"https://api.github.com/repos/tencentyun/wafer2-quickstart","labels_url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/10/comments","events_url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/10/events","html_url":"https://github.com/tencentyun/wafer2-quickstart/issues/10","id":331268697,"node_id":"MDU6SXNzdWUzMzEyNjg2OTc=","number":10,"title":"关于微信登录接口切换，Wafer2 SDK 及 Demo 更新公告","user":{"login":"jas0ncn","id":3380894,"node_id":"MDQ6VXNlcjMzODA4OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3380894?v=4","gravatar_id":"","url":"https://api.github.com/users/jas0ncn","html_url":"https://github.com/jas0ncn","followers_url":"https://api.github.com/users/jas0ncn/followers","following_url":"https://api.github.com/users/jas0ncn/following{/other_user}","gists_url":"https://api.github.com/users/jas0ncn/gists{/gist_id}","starred_url":"https://api.github.com/users/jas0ncn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jas0ncn/subscriptions","organizations_url":"https://api.github.com/users/jas0ncn/orgs","repos_url":"https://api.github.com/users/jas0ncn/repos","events_url":"https://api.github.com/users/jas0ncn/events{/privacy}","received_events_url":"https://api.github.com/users/jas0ncn/received_events","type":"User","site_admin":false},"labels":[{"id":675506839,"node_id":"MDU6TGFiZWw2NzU1MDY4Mzk=","url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-06-11T16:52:26Z","updated_at":"2018-09-14T23:38:18Z","closed_at":"2018-06-19T17:34:48Z","author_association":"MEMBER","body":"首先，感谢大家一直以来对 Wafer2 的支持，我们也都有关注 Github 上各位的 Issue，由于工作繁忙，有不及时回复之处尽请谅解！\r\n\r\n本公告主要对微信前不久调整登录接口后，Wafer2 的更新进行说明。需要注意的是，微信的登录接口更新与腾讯云无关，登录接口反馈的相关问题请至[微信开发者社区](https://developers.weixin.qq.com/)。\r\n\r\n微信公告：https://developers.weixin.qq.com/blogdetail?action=get_post_info&lang=zh_CN&token=&docid=0000a26e1aca6012e896a517556c01\r\n\r\n根据微信公告，`wx.getUserInfo` 接口将**不再弹窗**，而改用 `<button>`。目前 Wafer2 的 Demo 已经切换，以下主要对 Wafer2 SDK 的实现进行说明。\r\n\r\nWafer2 SDK 的授权登录模式改为：前端 `<button>` 弹出登录框，用户点击授权之后，SDK 调用 `wx.login` 和 `wx.getUserInfo` 获取用户信息，并解密，存储数据库。\r\n\r\n微信的 `wx.getUserInfo` 返回了包含加密信息的用户数据，我们需要使用 `session_key` 进行解密，而 `session_key` 需要使用 `wx.login` 接口调用。由于使用 `<button>` 点击事件中的 `userinfo` 是在 `wx.login` 获取的 `code` 之前，后面获取的 `code` 可能会导致解密失败。所以 SDK 内部统一重新调用 `wx.getUserInfo` 重新获取了一次用户信息。（https://github.com/tencentyun/wafer2-client-sdk/blob/master/lib/login.js#L63）\r\n\r\n此次调整新增一个功能。考虑到用户可能此前登录过，实际上通过 `openid` 就能查询到用户，所以此次新增了一个 `loginWithCode` 的接口，本接口内部只调用 `wx.login` 获取了 `code`，后端 SDK 使用 `code` 换取的 `openid` 查询数据库得到用户信息，并更新登录态。调整之后，`request` 模块将全部更新使用 `loginWithCode`。\r\n\r\n除此以外，Demo 也删除了使用 `wx.checkSession` 判断登录态的方式，由于登录态是后端自行颁发，所以无法使用微信的接口判断登录态。\r\n\r\n**注意 2.0 版本以上的 Client SDK 需配合 1.4.x 以上版本的 Node.js SDK 或者 2.2.x 以上版本的 PHP SDK。**\r\n\r\n此次调整给大家带来不便敬请谅解！关于登录模块调整的任何问题可以在下面留言。"},"comment":{"url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/comments/421510772","html_url":"https://github.com/tencentyun/wafer2-quickstart/issues/10#issuecomment-421510772","issue_url":"https://api.github.com/repos/tencentyun/wafer2-quickstart/issues/10","id":421510772,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTUxMDc3Mg==","user":{"login":"jas0ncn","id":3380894,"node_id":"MDQ6VXNlcjMzODA4OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3380894?v=4","gravatar_id":"","url":"https://api.github.com/users/jas0ncn","html_url":"https://github.com/jas0ncn","followers_url":"https://api.github.com/users/jas0ncn/followers","following_url":"https://api.github.com/users/jas0ncn/following{/other_user}","gists_url":"https://api.github.com/users/jas0ncn/gists{/gist_id}","starred_url":"https://api.github.com/users/jas0ncn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jas0ncn/subscriptions","organizations_url":"https://api.github.com/users/jas0ncn/orgs","repos_url":"https://api.github.com/users/jas0ncn/repos","events_url":"https://api.github.com/users/jas0ncn/events{/privacy}","received_events_url":"https://api.github.com/users/jas0ncn/received_events","type":"User","site_admin":false},"created_at":"2018-09-14T23:38:18Z","updated_at":"2018-09-14T23:38:18Z","author_association":"MEMBER","body":"@linrx1511 不需要用户授权的话登录的逻辑十分简单，没有比较实用 SDK 再次封装，直接调用 `wx.login` 接口即可~"}}
{"actor":{"display_login":"jas0ncn"}}