Fixes missing slack credentials

pull/2680/head^2
zomars 2022-05-05 16:15:40 -06:00
parent 1a79e0624c
commit f839fd2bb4
2 changed files with 10 additions and 7 deletions

View File

@ -5,11 +5,6 @@ import _package from "./package.json";
export const metadata = {
name: "Slack App",
description: _package.description,
installed: !!(
process.env.SLACK_CLIENT_ID &&
process.env.SLACK_CLIENT_SECRET &&
process.env.SLACK_SIGNING_SECRET
),
category: "messaging",
imageSrc: "/apps/slack.svg",
logo: "/apps/slack.svg",

View File

@ -3,8 +3,10 @@ import { stringify } from "querystring";
import prisma from "@calcom/prisma";
const client_id = process.env.SLACK_CLIENT_ID;
const client_secret = process.env.SLACK_CLIENT_SECRET;
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
let client_id = "";
let client_secret = "";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (!req.session?.user?.id) {
@ -19,6 +21,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.redirect("/apps/installed"); // Redirect to where the user was if they cancel the signup or if the oauth fails
}
const appKeys = await getAppKeysFromSlug("slack");
if (typeof appKeys.client_id === "string") client_id = appKeys.client_id;
if (typeof appKeys.client_secret === "string") client_secret = appKeys.client_secret;
if (!client_id) return res.status(400).json({ message: "Slack client_id missing" });
if (!client_secret) return res.status(400).json({ message: "Slack client_secret missing" });
const query = {
client_secret,
client_id,