feat: 认证管理实时获取token

This commit is contained in:
SikongJueluo 2025-08-13 14:36:01 +08:00
parent efcdee2109
commit 76342553ad
No known key found for this signature in database
1 changed files with 2 additions and 14 deletions

View File

@ -212,30 +212,18 @@ export class AuthManager {
} }
public static createAuthenticatedJtagHubConnection() { public static createAuthenticatedJtagHubConnection() {
const token = this.getToken();
if (isNull(token)) {
router.push("/login");
throw Error("Token Null!");
}
return new HubConnectionBuilder() return new HubConnectionBuilder()
.withUrl("http://127.0.0.1:5000/hubs/JtagHub", { .withUrl("http://127.0.0.1:5000/hubs/JtagHub", {
accessTokenFactory: () => token, accessTokenFactory: () => this.getToken() ?? "",
}) })
.withAutomaticReconnect() .withAutomaticReconnect()
.build(); .build();
} }
public static createAuthenticatedProgressHubConnection() { public static createAuthenticatedProgressHubConnection() {
const token = this.getToken();
if (isNull(token)) {
router.push("/login");
throw Error("Token Null!");
}
return new HubConnectionBuilder() return new HubConnectionBuilder()
.withUrl("http://127.0.0.1:5000/hubs/ProgressHub", { .withUrl("http://127.0.0.1:5000/hubs/ProgressHub", {
accessTokenFactory: () => token, accessTokenFactory: () => this.getToken() ?? "",
}) })
.withAutomaticReconnect() .withAutomaticReconnect()
.build(); .build();