Move redirect uri generation to getRedirectUri function of Connection class.

Use api_endpointPublic instead of cdn_endpointPublic
This commit is contained in:
Madeline
2023-03-18 19:33:32 -04:00
committed by Puyodead1
parent 9d5c5a8292
commit c7277efbad
15 changed files with 45 additions and 138 deletions
+1 -1
View File
@@ -20,5 +20,5 @@ export class ApiConfiguration {
defaultVersion: string = "9";
activeVersions: string[] = ["6", "7", "8", "9"];
useFosscordEnhancements: boolean = true;
endpointPublic: string = "/api";
endpointPublic: string | null = null;
}
+11 -1
View File
@@ -1,7 +1,7 @@
import crypto from "crypto";
import { ConnectedAccount } from "../entities";
import { ConnectedAccountSchema, ConnectionCallbackSchema } from "../schemas";
import { DiscordApiErrors } from "../util";
import { Config, DiscordApiErrors } from "../util";
/**
* A connection that can be used to connect to an external service.
@@ -19,6 +19,16 @@ export default abstract class Connection {
*/
abstract getAuthorizationUrl(userId: string): string;
/**
* Returns the redirect_uri for a connection type
* @returns redirect_uri for this connection
*/
getRedirectUri() {
const endpointPublic =
Config.get().api.endpointPublic ?? "http://localhost:3001";
return `${endpointPublic}/connections/${this.id}/callback`;
}
/**
* Processes the callback
* @param args Callback arguments