Fix the problem of resolving authentication in template when using curl or ab command (#3909)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.6.x

#### What this PR does / why we need it:

When we use curl or ab command to access any pages rendered by thymeleaf at first up, we will get the error described in <https://github.com/halo-dev/halo/issues/3861>.

This PR will resolve the problem by checking null value.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3861

#### Does this PR introduce a user-facing change?

```release-note
解决访问页面无法渲染的问题
```
pull/3917/head
John Niang 2023-05-08 16:47:41 +08:00 committed by GitHub
parent acceeee59c
commit 8ffdb5ed1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -34,7 +34,8 @@ public class ReactivePropertyAccessor implements PropertyAccessor {
if (isReactiveType(target)) {
return true;
}
List<PropertyAccessor> propertyAccessors = context.getPropertyAccessors();
var propertyAccessors =
getPropertyAccessorsToTry(target.getClass(), context.getPropertyAccessors());
for (PropertyAccessor propertyAccessor : propertyAccessors) {
if (propertyAccessor.canRead(context, target, name)) {
return true;
@ -83,7 +84,7 @@ public class ReactivePropertyAccessor implements PropertyAccessor {
private boolean isReactiveType(Object target) {
if (target == null) {
return false;
return true;
}
Class<?> clazz = target.getClass();
return Mono.class.isAssignableFrom(clazz)