Skip to content

Commit

Permalink
Roll back AuthManager change so "auth-success" event gets a dictionar…
Browse files Browse the repository at this point in the history
…y passed
  • Loading branch information
Samuel Albert committed Jan 2, 2025
1 parent f0ad816 commit a08f0f2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/backend/auth/auth-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class AuthManager extends TypedEmitter<AuthManagerEvents> {
}

successfulAuth(providerId: string, tokenData: AuthDetails): void {
this.emit("auth-success", providerId, tokenData);
this.emit("auth-success", { "providerId": providerId, "tokenData": tokenData});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/auth/auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface AuthDetails {
}

export interface AuthManagerEvents {
"auth-success": (providerId: string, tokenData: AuthDetails) => void
"auth-success": (data: { providerId: string, tokenData: AuthDetails }) => void
}

export declare class AuthManager extends TypedEmitter<AuthManagerEvents> {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/auth/twitch-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async function getUserCurrent(accessToken: string) {
return null;
}

authManager.on("auth-success", async (providerId, tokenData) => {
authManager.on("auth-success", async ({providerId, tokenData}) => {

if (providerId === twitchAuthProviders.streamerAccountProviderId
|| providerId === twitchAuthProviders.botAccountProviderId) {
Expand Down
4 changes: 1 addition & 3 deletions src/backend/integrations/integration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IntegrationManager extends TypedEmitter<IntegrationManagerEvents> {

constructor() {
super();
authManager.on("auth-success", (providerId, tokenData) => {
authManager.on("auth-success", ({providerId, tokenData}) => {
const int = this._integrations.find(i => i.definition.linkType === "auth" &&
i.definition.authProviderDetails.id === providerId);
if (int != null) {
Expand Down Expand Up @@ -469,8 +469,6 @@ frontEndCommunicator.on("integrationUserSettingsUpdate", (integrationData: Integ
}
});

// TODO: The day the frontend is moved to typescript, this arguments list needs to be flattened
// Having a dict here allows to tell the frontend what goes where for now
frontEndCommunicator.onAsync<[{ integrationId: string, accountId: string }]>("enteredIntegrationAccountId", async (idData) => {
const { integrationId, accountId } = idData;
const int = integrationManager.getIntegrationById(integrationId);
Expand Down

0 comments on commit a08f0f2

Please sign in to comment.