Skip to content

Commit 9559653

Browse files
fix: add missing check for organization data in form login command
Added a check to ensure that the organization data retrieved during the form login enablement process is valid. This prevents potential errors when the organization with the specified slug is not found in the database.
1 parent b2bab20 commit 9559653

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

app/client/packages/rts/src/ctl/enable_form_login.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function run() {
3232
]);
3333

3434
const orgData = JSON.parse(orgCheckResult);
35+
3536
if (!orgData || !orgData._id) {
3637
throw new Error("Organization with slug 'default' not found in database");
3738
}

app/client/packages/rts/src/ctl/utils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Constants from "./constants";
33
import childProcess from "child_process";
44
import fs from "node:fs";
55
import { ConnectionString } from "mongodb-connection-string-url";
6-
import { parse } from "acorn";
76

87
export function showHelp() {
98
console.log(
@@ -44,17 +43,19 @@ export function parseRedisUrl(redisUrlObject) {
4443
if (redisUrlObject && redisUrlObject !== "undefined") {
4544
try {
4645
const redisUrl = new URL(redisUrlObject);
46+
4747
return redisUrl.hostname;
4848
} catch (err) {
4949
console.error("Error parsing redis URL:", err);
5050
}
5151
}
52+
5253
return null;
5354
}
5455

5556
export function getRedisUrl() {
56-
let redisUrl = null;
57-
let redisUrlObject = process.env.APPSMITH_REDIS_URL;
57+
const redisUrlObject = process.env.APPSMITH_REDIS_URL;
58+
5859
// Make sure redisUrl takes precedence over process.env.APPSMITH_REDIS_URL
5960
if (redisUrlObject && redisUrlObject !== "undefined") {
6061
try {
@@ -63,6 +64,7 @@ export function getRedisUrl() {
6364
console.error("Error parsing redis URL from environment variable:", err);
6465
}
6566
}
67+
6668
// If environment variable APPSMITH_REDIS_URL is not set, read from the environment file
6769
try {
6870
const env_array = fs
@@ -75,13 +77,15 @@ export function getRedisUrl() {
7577
const redisUrl = parseRedisUrl(
7678
env_array[i].toString().split("=")[1].trim(),
7779
);
78-
break;
80+
81+
return redisUrl;
7982
}
8083
}
8184
} catch (err) {
8285
console.error("Error reading the environment file:", err);
8386
}
84-
return redisUrl;
87+
88+
return null;
8589
}
8690

8791
export function getDburl() {

0 commit comments

Comments
 (0)