|
|
@@ -7,6 +7,7 @@ import com.auth0.jwt.algorithms.Algorithm;
|
|
|
import com.auth0.jwt.interfaces.Claim;
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
import com.template.model.pojo.RepairAdmin;
|
|
|
+import com.template.model.pojo.SmartUser;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.util.Date;
|
|
|
@@ -31,7 +32,7 @@ public class JWTUtil {
|
|
|
* 生成token 有过期时间
|
|
|
* @return 返回token
|
|
|
*/
|
|
|
- public static String getToken(RepairAdmin ra){
|
|
|
+ public static String getToken(SmartUser user){
|
|
|
|
|
|
// 签发时间
|
|
|
Date iatDate = new Date();
|
|
|
@@ -46,8 +47,7 @@ public class JWTUtil {
|
|
|
map.put("typ", "JWT");
|
|
|
String token = JWT.create()
|
|
|
.withHeader(map) // header
|
|
|
- .withClaim("account", ra.getAccount()) // 账号
|
|
|
- .withClaim("password", ra.getPassword()) // 密码
|
|
|
+ .withClaim("cardNo", user.getCardNo()) // 账号
|
|
|
.withExpiresAt(new Date(CommonUtil.getCurrentTimestamp() + EXPIRED)) // 设置过期时间。过期时间要大于签发时间
|
|
|
.withIssuedAt(iatDate) // 设置签发时间
|
|
|
.sign(Algorithm.HMAC256(SIGNATURE)); // 加密
|
|
|
@@ -86,8 +86,6 @@ public class JWTUtil {
|
|
|
return JWT.require(Algorithm.HMAC256(SIGNATURE)).build().verify(token);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/*
|
|
|
* 解密Token
|
|
|
* */
|