From: Tang Cheng Date: Wed, 19 Jun 2019 07:06:22 +0000 (+0800) Subject: chore: 修改 pointcut 通过 securitycontextholder 取出用户 X-Git-Tag: 1.0.0^2~160 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=20110a0c8941cd295f4258e14a0e3ff05680383a;p=epayment%2Ffood_payapi.git chore: 修改 pointcut 通过 securitycontextholder 取出用户 --- diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt index 0f9f3149..092fde81 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.http.ResponseEntity import org.springframework.security.core.Authentication +import org.springframework.security.core.context.SecurityContextHolder import org.springframework.stereotype.Component import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice @@ -63,13 +64,16 @@ class RestControllerAspect { fun postmapping() { } - @Around("restcontroller() && postmapping() && args(@RequestBody body, auth, ..)") + @Around("restcontroller() && postmapping() && args(@RequestBody body, ..)") @Throws(Throwable::class) - fun logPostMethods(joinPoint: ProceedingJoinPoint, body: Any, auth: Authentication): Any { + fun logPostMethods(joinPoint: ProceedingJoinPoint, body: Any): Any { return try { if (body is APIRequestParam) { body.checkParam() - if (requestSignCheck && !body.checkSign(commonService.getSecretByAppid(auth.name))) { + + if (requestSignCheck && + !body.checkSign(commonService.getSecretByAppid( + SecurityContextHolder.getContext().authentication.name))) { throw RequestParamCheckException(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误") } } else {