提交 fe05ee3c 作者: 余乾开

Merge branch 'release/0.0.529-1530'

...@@ -31,23 +31,22 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor { ...@@ -31,23 +31,22 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//扫码登录还没做好,暂时先注释 String requestURI = request.getRequestURI();
// String requestURI = request.getRequestURI(); //根据uri确认是否要拦截
// //根据uri确认是否要拦截 if (!shouldFilter(requestURI)){
// if (!shouldFilter(requestURI)){ return true;
// return true; }
// } String token = request.getHeader("token");
// String token = request.getHeader("token"); String tokenJson = stringRedisTemplate.opsForValue().get(token);
// String tokenJson = stringRedisTemplate.opsForValue().get(token);
// if (StringUtils.isBlank(tokenJson)){
// if (StringUtils.isBlank(tokenJson)){ exceptionProcess(response);
// exceptionProcess(response); return false;
// return false; }
// } LoginSuccessDTO loginSuccessDTO = JSONObject.parseObject(tokenJson, LoginSuccessDTO.class);
// LoginSuccessDTO loginSuccessDTO = JSONObject.parseObject(tokenJson, LoginSuccessDTO.class); if (loginSuccessDTO != null){
// if (loginSuccessDTO != null){ request.setAttribute("userAccountId", loginSuccessDTO.getUserAccountId());
// request.setAttribute("userAccountId", loginSuccessDTO.getUserAccountId()); }
// }
return true; return true;
} }
......
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.AuthService;
import com.mmc.iuav.user.service.UserAccountService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* @author: zj
* @Date: 2023/5/29 14:37
*/
@Api(tags = "临时登录授权")
@RequestMapping("/temp-auth/")
@RestController
public class TempLoginController extends BaseController{
@Autowired
private AuthService authService;
@ApiOperation(value = "小程序确认登录")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("tempConfirmLogin")
public ResultBody tempConfirmLogin(HttpServletRequest request, @ApiParam(value = "临时登录code",example = "kj6d9wcxyp92jajugdnc") @RequestParam String randomLoginCode){
return authService.tempConfirmLogin(this.getUserLoginInfoFromRedis(request), randomLoginCode);
}
@ApiOperation(value = "查询登录信息")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("getLoginInfo")
public ResultBody getLoginInfo(@ApiParam(value = "临时登录code",example = "kj6d9wcxyp92jajugdnc") @RequestParam String randomLoginCode){
return authService.getLoginInfo(randomLoginCode);
}
}
package com.mmc.iuav.user.service; package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.qo.LoginUserQO; import com.mmc.iuav.user.model.qo.LoginUserQO;
import com.mmc.iuav.user.model.vo.WxLoginVO; import com.mmc.iuav.user.model.vo.WxLoginVO;
...@@ -29,4 +30,19 @@ public interface AuthService { ...@@ -29,4 +30,19 @@ public interface AuthService {
* @return * @return
*/ */
ResultBody testAppletLogin(String unionId); ResultBody testAppletLogin(String unionId);
/**
* 小程序确认登录
* @param loginSuccessDTO
* @param randomLoginCode
* @return
*/
ResultBody tempConfirmLogin(LoginSuccessDTO loginSuccessDTO, String randomLoginCode);
/**
* 获取用登录信息
* @param randomLoginCode
* @return
*/
ResultBody getLoginInfo(String randomLoginCode);
} }
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.auth.JwtConstant; import com.mmc.iuav.auth.JwtConstant;
import com.mmc.iuav.auth.JwtUtil; import com.mmc.iuav.auth.JwtUtil;
import com.mmc.iuav.general.CodeUtil; import com.mmc.iuav.general.CodeUtil;
import com.mmc.iuav.http.BizException;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum; import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.auth.PwdUtil; import com.mmc.iuav.user.auth.PwdUtil;
...@@ -171,4 +172,22 @@ public class AuthServiceImpl implements AuthService { ...@@ -171,4 +172,22 @@ public class AuthServiceImpl implements AuthService {
} }
return ResultBody.error(ResultEnum.APPLET_LOGIN_ERROR); return ResultBody.error(ResultEnum.APPLET_LOGIN_ERROR);
} }
@Override
public ResultBody tempConfirmLogin(LoginSuccessDTO loginSuccessDTO, String randomLoginCode) {
stringRedisTemplate.opsForValue().set(
randomLoginCode, JSONObject.toJSONString(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
return ResultBody.success();
}
@Override
public ResultBody getLoginInfo(String randomLoginCode) {
String json = stringRedisTemplate.opsForValue().get(randomLoginCode);
if (org.apache.commons.lang3.StringUtils.isBlank(json)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
LoginSuccessDTO loginSuccessDTO = JSONObject.parseObject(json, LoginSuccessDTO.class);
return ResultBody.success(loginSuccessDTO);
}
} }
...@@ -10,3 +10,5 @@ data-filter: ...@@ -10,3 +10,5 @@ data-filter:
- /userapp/auth/backEndLogin - /userapp/auth/backEndLogin
- /userapp/auth/testAppletLogin - /userapp/auth/testAppletLogin
- /userapp/cooperation/listTag - /userapp/cooperation/listTag
- /userapp/temp-auth/getLoginInfo
- /userapp/wx/getAppletQRCode
...@@ -17,4 +17,4 @@ patches: ...@@ -17,4 +17,4 @@ patches:
images: images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG - name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: c806874e936588535446245fc63b8acc7dd8db5a newTag: 13be77b9442adcdd8179b15401887443f494edca
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论