Skip to content

Commit

Permalink
fix: handle missing name for social bingding (#57)
Browse files Browse the repository at this point in the history
### What this PR does?
修复 GitHub 显示名称未设置时无法绑定的问题

/kind bug

Fixes #51 
Fixes #14

```release-note
修复 GitHub 显示名称未设置时无法绑定的问题
```
  • Loading branch information
guqing authored Aug 2, 2024
1 parent 6299f36 commit 8d5ad2b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/run/halo/oauth/UserConnectionServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.web.server.ServerWebInputException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.UserConnection;
Expand Down Expand Up @@ -112,7 +111,8 @@ UserConnection convert(String username, OAuth2LoginAuthenticationToken authentic

Oauth2UserProfile oauth2UserProfile =
oauth2UserProfileMapperManager.mapProfile(registrationId, oauth2User);
spec.setDisplayName(oauth2UserProfile.getDisplayName());
var displayName = StringUtils.defaultIfBlank(oauth2UserProfile.getDisplayName(), username);
spec.setDisplayName(displayName);
spec.setAvatarUrl(oauth2UserProfile.getAvatarUrl());
spec.setProfileUrl(oauth2UserProfile.getProfileUrl());
return userConnection;
Expand Down

0 comments on commit 8d5ad2b

Please sign in to comment.