Skip to content

Commit

Permalink
Compute in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Mar 11, 2024
1 parent f58270a commit da480c2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/utils/rfdApiStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class RfdApiStrategy<User extends ExpiringUser> extends OAuth2Strategy<
RfdApiExtraParams
> {
public name = `rfd-api`
protected host = ``
protected userInfoUrl = ``

constructor(
{ host, clientID, clientSecret, callbackURL, remoteProvider, scope }: RfdApiStrategyOptions,
Expand All @@ -107,11 +107,7 @@ export class RfdApiStrategy<User extends ExpiringUser> extends OAuth2Strategy<
)
this.name = `${this.name}-${remoteProvider}`
this.scope = this.parseScope(scope)
this.host = host
}

protected userInfoUrl(): string {
return `${this.host}/self`
this.userInfoUrl = `${host}/self`
}

protected authorizationParams(): URLSearchParams {
Expand All @@ -120,7 +116,7 @@ export class RfdApiStrategy<User extends ExpiringUser> extends OAuth2Strategy<
}

protected async userProfile(accessToken: string): Promise<RfdApiProfile> {
const response = await fetch(this.userInfoUrl(), {
const response = await fetch(this.userInfoUrl, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
Expand Down

0 comments on commit da480c2

Please sign in to comment.