登录调整
This commit is contained in:
@@ -101,26 +101,16 @@ public class LoginContoller {
|
|||||||
// @RequestParam(value = "rawData", required = false) String rawData,
|
// @RequestParam(value = "rawData", required = false) String rawData,
|
||||||
// @RequestParam(value = "signature", required = false) String signature
|
// @RequestParam(value = "signature", required = false) String signature
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||||
Result.fail("code不能为空");
|
Result.fail("code不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = map.get("code").toString();
|
String code = map.get("code").toString();
|
||||||
|
|
||||||
// String qrCode = map.get("qrCode");
|
|
||||||
|
|
||||||
String rawData = map.get("rawData");
|
String rawData = map.get("rawData");
|
||||||
|
|
||||||
String signature = map.get("signature");
|
String signature = map.get("signature");
|
||||||
|
String encryptedData = map.get("encryptedData");
|
||||||
// String encryptedData = map.get("encryptedData");
|
String ivStr = map.get("iv");
|
||||||
//
|
// String phone = map.get("phone");
|
||||||
// String ivStr = map.get("iv");
|
log.info("登录传参:入参:{}",JSONUtil.toJSONString(map));
|
||||||
|
|
||||||
String phone = map.get("phone");
|
|
||||||
|
|
||||||
// 用户非敏感信息:rawData
|
// 用户非敏感信息:rawData
|
||||||
// 签名:signature
|
// 签名:signature
|
||||||
JSONObject rawDataJson = JSON.parseObject(rawData);
|
JSONObject rawDataJson = JSON.parseObject(rawData);
|
||||||
@@ -136,12 +126,12 @@ public class LoginContoller {
|
|||||||
if (!signature.equals(signature2)) {
|
if (!signature.equals(signature2)) {
|
||||||
return Result.fail("签名校验失败");
|
return Result.fail("签名校验失败");
|
||||||
}
|
}
|
||||||
|
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
||||||
|
log.info("登录传参:解码获取手机号{}",data);
|
||||||
|
String phone =JSONObject.parseObject(data).get("phoneNumber").toString();
|
||||||
String nickName = rawDataJson.getString("nickName");
|
String nickName = rawDataJson.getString("nickName");
|
||||||
String avatarUrl = rawDataJson.getString("avatarUrl");
|
String avatarUrl = rawDataJson.getString("avatarUrl");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, qrCode, IpUtil.getIpAddr(request));
|
|
||||||
return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, IpUtil.getIpAddr(request));
|
return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, IpUtil.getIpAddr(request));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -158,7 +148,7 @@ public class LoginContoller {
|
|||||||
* @param map
|
* @param map
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("getPhoneNumber")
|
// @RequestMapping("getPhoneNumber")
|
||||||
public Result getPhoneNumber(@RequestBody Map<String, String> map) {
|
public Result getPhoneNumber(@RequestBody Map<String, String> map) {
|
||||||
|
|
||||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||||
@@ -180,12 +170,13 @@ public class LoginContoller {
|
|||||||
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
||||||
try {
|
try {
|
||||||
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
||||||
|
log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
|
||||||
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
|
log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data);
|
||||||
}
|
}
|
||||||
return Result.fail("获取手机号失败");
|
return Result.fail("获取手机号失败,请重试!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class LoginService {
|
|||||||
//展示描述
|
//展示描述
|
||||||
//图标
|
//图标
|
||||||
// map.put("", );
|
// map.put("", );
|
||||||
log.info("登录结果:" + JSONUtil.toJSONString(map));
|
log.info("登录传参 结果:" + JSONUtil.toJSONString(map));
|
||||||
return Result.success(CodeEnum.SUCCESS, map);
|
return Result.success(CodeEnum.SUCCESS, map);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user