提交 e7ef0b47 authored 作者: linzhenjie's avatar linzhenjie

加校验token接口

上级 b7f5515d
...@@ -2,6 +2,7 @@ package tech.glinfo.enbao.modules.appuser.controller; ...@@ -2,6 +2,7 @@ package tech.glinfo.enbao.modules.appuser.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
...@@ -16,6 +17,7 @@ import org.apache.http.util.EntityUtils; ...@@ -16,6 +17,7 @@ import org.apache.http.util.EntityUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import tech.glinfo.enbao.common.annotation.ApiLog; import tech.glinfo.enbao.common.annotation.ApiLog;
...@@ -279,7 +281,7 @@ public class AppUserController extends AbstractController { ...@@ -279,7 +281,7 @@ public class AppUserController extends AbstractController {
if (StringUtils.isNotEmpty(unionid)) {//苹果登录 if (StringUtils.isNotEmpty(unionid)) {//苹果登录
//open_id 存unionID //open_id 存unionID
AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("unionid", unionid)); AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("open_id", unionid));
if (user != null) { if (user != null) {
// map.put("openId", openId); // map.put("openId", openId);
return R.ok(genTokenAndGetData(user, clientId, role)); return R.ok(genTokenAndGetData(user, clientId, role));
...@@ -606,4 +608,19 @@ public class AppUserController extends AbstractController { ...@@ -606,4 +608,19 @@ public class AppUserController extends AbstractController {
return R.ok(result); return R.ok(result);
} }
@PostMapping("checkToken")
public R checkToken(@RequestBody Map<String, Object> params) {
String token = (String) params.get("token");
if(StringUtils.isNotEmpty(token)) {
Claims claims = jwtUtils.getClaimByToken(token);
if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){
return R.error("no login or expired!");
} else {
return R.ok();
}
}
return R.error();
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论