|
@@ -4,6 +4,8 @@ import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import com.zkqy.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -76,6 +78,27 @@ public class TokenService
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 验证当前用户是否为admin
|
|
|
+ *
|
|
|
+ * @return 用户信息
|
|
|
+ */
|
|
|
+ public boolean getLoginUserIsAdminByToken(String token) {
|
|
|
+ if (StringUtils.isNotEmpty(token)) {
|
|
|
+ try {
|
|
|
+ String uuid = "";
|
|
|
+ Claims claims = parseToken(token);
|
|
|
+ // 解析对应的权限以及用户信息
|
|
|
+ uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
|
|
|
+ String userKey = getTokenKey(uuid);
|
|
|
+ LoginUser user = redisCache.getCacheObject(userKey);
|
|
|
+ return SecurityUtils.isAdmin(user.getUserId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 设置用户身份信息
|