mirror of https://github.com/halo-dev/halo
fix: initializes a ghost user by default to replace that the users that has been deleted (#3344)
#### What type of PR is this? /kind bug #### What this PR does / why we need it: 系统默认初始化一个 ghost 用户,用于表示用户已删除。 #### Which issue(s) this PR fixes: Fixes #3317 ```release-note NONE ```pull/3341/head^2
parent
e49baa1cf8
commit
2139244a62
|
@ -13,11 +13,4 @@ public class Contributor {
|
|||
private String displayName;
|
||||
private String avatar;
|
||||
private String name;
|
||||
|
||||
public static Contributor getGhost() {
|
||||
Contributor contributor = new Contributor();
|
||||
contributor.setName("ghost");
|
||||
contributor.setDisplayName("已删除用户");
|
||||
return contributor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,15 +224,15 @@ public class PostServiceImpl extends AbstractContentService implements PostServi
|
|||
return Flux.empty();
|
||||
}
|
||||
return Flux.fromIterable(usernames)
|
||||
.flatMap(username -> client.fetch(User.class, username))
|
||||
.flatMap(username -> client.fetch(User.class, username)
|
||||
.switchIfEmpty(Mono.defer(() -> client.fetch(User.class, "ghost"))))
|
||||
.map(user -> {
|
||||
Contributor contributor = new Contributor();
|
||||
contributor.setName(user.getMetadata().getName());
|
||||
contributor.setDisplayName(user.getSpec().getDisplayName());
|
||||
contributor.setAvatar(user.getSpec().getAvatar());
|
||||
return contributor;
|
||||
})
|
||||
.defaultIfEmpty(Contributor.getGhost());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,3 +6,15 @@ spec:
|
|||
displayName: Anonymous User
|
||||
email: anonymous@example.com
|
||||
disabled: true
|
||||
|
||||
---
|
||||
apiVersion: v1alpha1
|
||||
kind: User
|
||||
metadata:
|
||||
name: ghost
|
||||
spec:
|
||||
displayName: 已删除用户
|
||||
email: ghost@example.com
|
||||
disabled: true
|
||||
bio: 该用户已被删除。
|
||||
|
||||
|
|
Loading…
Reference in New Issue