Simplify place-id/apiKey validation logic per review feedback
This commit is contained in:
parent
a1ee29a1b8
commit
689f2b5a6e
|
|
@ -103,13 +103,9 @@ router.post('/places', (req, res) => {
|
||||||
return res.status(403).json({ success: false, message: "Only admins can set a custom place id or API key" });
|
return res.status(403).json({ success: false, message: "Only admins can set a custom place id or API key" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canSetCustomValues) {
|
// If we reach here, either the caller is an admin, or both id and apiKey were already falsy.
|
||||||
id = '';
|
id = id ? String(id).trim() : '';
|
||||||
apiKey = '';
|
apiKey = apiKey ? String(apiKey).trim() : '';
|
||||||
} else {
|
|
||||||
id = id ? String(id).trim() : '';
|
|
||||||
apiKey = apiKey ? String(apiKey).trim() : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!id) id = generatePlaceId();
|
if (!id) id = generatePlaceId();
|
||||||
if (!apiKey) apiKey = generateApiKey();
|
if (!apiKey) apiKey = generateApiKey();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue