Improved API key error message for SendGrid setup page (#8847)

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
Praveen Dias 2023-05-12 04:34:10 +05:30 committed by GitHub
parent b44e5a7aae
commit 078c9ddca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -15,7 +15,13 @@ export async function getHandler(req: NextApiRequest) {
const { api_key } = req.body;
if (!api_key) throw new HttpError({ statusCode: 400, message: "No Api Key provided to check" });
const encrypted = symmetricEncrypt(JSON.stringify({ api_key }), process.env.CALENDSO_ENCRYPTION_KEY || "");
let encrypted;
try {
encrypted = symmetricEncrypt(JSON.stringify({ api_key }), process.env.CALENDSO_ENCRYPTION_KEY || "");
} catch (reason) {
logger.error("Could not add Sendgrid app", reason);
throw new HttpError({ statusCode: 500, message: "Invalid length - CALENDSO_ENCRYPTION_KEY" });
}
const data = {
type: "sendgrid_other_calendar",

View File

@ -84,7 +84,7 @@ export default function SendgridSetup() {
onBlur={onBlur}
disabled={testPassed === true}
name="api_key"
placeholder="api_xyz..."
placeholder="SG.xxxxxx..."
onChange={async (e) => {
onChange(e.target.value);
form.setValue("api_key", e.target.value);