mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 12:51:03 +00:00
fix: user data not being correctly loaded on hydra api setup
This commit is contained in:
@@ -23,7 +23,7 @@ interface HydraApiUserAuth {
|
||||
authToken: string;
|
||||
refreshToken: string;
|
||||
expirationTimestamp: number;
|
||||
subscription: { expiresAt: Date | null } | null;
|
||||
subscription: { expiresAt: Date | string | null } | null;
|
||||
}
|
||||
|
||||
export class HydraApi {
|
||||
@@ -182,8 +182,6 @@ export class HydraApi {
|
||||
);
|
||||
}
|
||||
|
||||
await getUserData();
|
||||
|
||||
const userAuth = await userAuthRepository.findOne({
|
||||
where: { id: 1 },
|
||||
relations: { subscription: true },
|
||||
@@ -197,6 +195,14 @@ export class HydraApi {
|
||||
? { expiresAt: userAuth.subscription?.expiresAt }
|
||||
: null,
|
||||
};
|
||||
|
||||
const updatedUserData = await getUserData();
|
||||
|
||||
this.userAuth.subscription = updatedUserData?.subscription
|
||||
? {
|
||||
expiresAt: updatedUserData.subscription.expiresAt,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
private static sendSignOutEvent() {
|
||||
@@ -284,10 +290,8 @@ export class HydraApi {
|
||||
await this.revalidateAccessTokenIfExpired();
|
||||
}
|
||||
|
||||
if (needsSubscription) {
|
||||
if (!(await this.hasActiveSubscription())) {
|
||||
throw new SubscriptionRequiredError();
|
||||
}
|
||||
if (needsSubscription && !this.hasActiveSubscription()) {
|
||||
throw new SubscriptionRequiredError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user