|
@@ -5,14 +5,9 @@ import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
import com.caimei365.user.service.LoginService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import reactor.core.publisher.Flux;
|
|
|
|
|
|
-import java.time.Duration;
|
|
|
import java.util.Map;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-import java.util.stream.IntStream;
|
|
|
|
|
|
/**
|
|
|
* 登录API
|
|
@@ -88,9 +83,8 @@ public class LoginApi {
|
|
|
* 流程:1.前端页面中先引入JS文件(支持https):http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js
|
|
|
* 2.后端提供接口(/user/login/auth/parameters)返回生成二维码的参数:appid,scope,redirect_uri,其余参数由前端自定义,详细参考微信文档:https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
|
|
|
* 3.前端实例化JS对象(用于生成二维码): new WxLogin({self_redirect:true, id:"login_container", appid:"", scope:"", redirect_uri:"", state:"", style:"", href: ""});
|
|
|
- * 4.前端生成二维码后订阅服务端SSE事件,等用户扫码完成后端通过SSE告诉前端。
|
|
|
- * 5.用户扫码:用户使用微信扫码授权后,微信服务器回调:/user/login/auth/scan?code=CODE&state=STATE,后端接口根据code和state换取access_token,并通过access_token获取用户信息,并存入Redis.
|
|
|
- * 6.前端通过监听SSE事件得到扫码完成的通知,发送登录请求(/user/login/auth/result)并获取用户数据(Redis取出)。
|
|
|
+ * 4.用户扫码:用户使用微信扫码授权后,微信服务器回调:/user/login/auth/scan?code=CODE&state=STATE,后端接口根据code和state换取access_token,并通过access_token获取用户信息,并存入Redis.
|
|
|
+ * 5.前端通过轮询(/user/login/auth/result)监听是否扫码完成,完成后获取用户数据(Redis取出)。
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -119,16 +113,16 @@ public class LoginApi {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验扫码结果(长链接),用户数据存入Redis,key前缀:wxInfo:website:
|
|
|
+ * 校验扫码结果,用户数据存入Redis,key前缀:wxInfo:website:
|
|
|
*
|
|
|
* spi旧接口:/user/polling,小程序sessionKey(wxInfo)、PC端sessionKey(wxInfoMap)
|
|
|
*
|
|
|
* @param state 安全认证key(第一步获取参数时自定义生成的uuid)
|
|
|
* @return UserLoginVo
|
|
|
*/
|
|
|
- @GetMapping("/auth/scan/check")
|
|
|
- public ResponseJson<UserLoginVo> checkScanAuthResult(String state){
|
|
|
- return loginService.checkScanAuthResult(state);
|
|
|
+ @GetMapping("/auth/scan/result")
|
|
|
+ public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state){
|
|
|
+ return loginService.qrCodeAuthScanResult(state);
|
|
|
}
|
|
|
|
|
|
}
|