Skip to content

Commit 223b0b7

Browse files
zhou9584Le Zhou
andauthored
Bugfix: Update AuthTokenService to load TeamAdminMap of user (#707)
<!-- Please provide brief information about the PR, what it contains & its purpose, new behaviors after the change. And let us know here if you need any help: https://github.com/microsoft/HydraLab/issues/new --> ## Description <!-- A few words to explain your changes --> ### Linked GitHub issue ID: # ## Pull Request Checklist <!-- Put an x in the boxes that apply. This is simply a reminder of what we are going to look for before merging your code. --> - [x] Tests for the changes have been added (for bug fixes / features) - [x] Code compiles correctly with all tests are passed. - [ ] I've read the [contributing guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code) and followed the recommended practices. - [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or [README](https://github.com/microsoft/HydraLab/blob/main/README.md) have been reviewed and added / updated if needed (for bug fixes / features) ### Does this introduce a breaking change? *If this introduces a breaking change for Hydra Lab users, please describe the impact and migration path.* - [ ] Yes - [x] No ## How you tested it *Please make sure the change is tested, you can test it by adding UTs, do local test and share the screenshots, etc.* Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Technical design - [ ] Build related changes - [ ] Refactoring (no functional changes, no api changes) - [ ] Code style update (formatting, renaming) or Documentation content changes - [ ] Other (please describe): ### Feature UI screenshots or Technical design diagrams *If this is a relatively large or complex change, kick it off by drawing the tech design with PlantUML and explaining why you chose the solution you did and what alternatives you considered, etc...* Co-authored-by: Le Zhou <zhoule@microsoft.com>
1 parent 49e280e commit 223b0b7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

center/src/main/java/com/microsoft/hydralab/center/service/AuthTokenService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.microsoft.hydralab.center.repository.AuthTokenRepository;
77
import com.microsoft.hydralab.center.util.AuthUtil;
88
import com.microsoft.hydralab.common.entity.center.AuthToken;
9+
import com.microsoft.hydralab.common.entity.center.SysUser;
910
import org.springframework.beans.factory.annotation.Autowired;
1011
import org.springframework.security.core.Authentication;
1112
import org.springframework.security.core.context.SecurityContextHolder;
@@ -87,9 +88,13 @@ public boolean setUserAuthByAppClientToken(String clientAadToken) {
8788
}
8889
String appClientId = authUtil.getAppClientId(clientAadToken);
8990
String teamId = teamAppManagementService.queryTeamIdByClientId(appClientId);
90-
Authentication authObj = userTeamManagementService.queryUsersByTeam(teamId).stream()
91+
SysUser sysUser = userTeamManagementService.queryUsersByTeam(teamId).stream()
9192
.findFirst()
9293
.orElse(null);
94+
if(sysUser == null){
95+
return false;
96+
}
97+
Authentication authObj = securityUserService.loadUserAuthentication(sysUser.getMailAddress(), null);
9398
if (authObj == null) {
9499
return false;
95100
}

0 commit comments

Comments
 (0)