Baikal CalDAV error hint (#6021)
This commit is contained in:
1 parent
3456cc5521
commit
a638708871
4 files changed
+40
-5
No files matched your search
@@ -920,7 +920,7 @@
|
||||
"allow_booker_to_select_duration": "Allow booker to select duration",
|
||||
"impersonate_user_tip": "All uses of this feature is audited.",
|
||||
"impersonating_user_warning": "Impersonating username \"{{user}}\".",
|
||||
"impersonating_stop_instructions": "<0>Click Here to stop</0>.",
|
||||
"impersonating_stop_instructions": "Click here to stop",
|
||||
"event_location_changed": "Updated - Your event changed the location",
|
||||
"location_changed_event_type_subject": "Location Changed: {{eventType}} with {{name}} at {{date}}",
|
||||
"current_location": "Current Location",
|
||||
|
||||
@@ -40,8 +40,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
await prisma.credential.create({
|
||||
data,
|
||||
});
|
||||
} catch (reason) {
|
||||
logger.error("Could not add this caldav account", reason);
|
||||
} catch (e) {
|
||||
logger.error("Could not add this caldav account", e);
|
||||
if (e instanceof Error) {
|
||||
let message = e.message;
|
||||
if (e.message.indexOf("Invalid credentials") > -1 && url.indexOf("dav.php") > -1) {
|
||||
const parsedUrl = new URL(url);
|
||||
const adminUrl =
|
||||
parsedUrl.protocol +
|
||||
"//" +
|
||||
parsedUrl.hostname +
|
||||
(parsedUrl.port ? ":" + parsedUrl.port : "") +
|
||||
"/admin/?/settings/standard/";
|
||||
message = `Couldn\'t connect to caldav account, please verify WebDAV authentication type is set to "Basic"`;
|
||||
return res.status(500).json({ message, actionUrl: adminUrl });
|
||||
}
|
||||
}
|
||||
return res.status(500).json({ message: "Could not add this caldav account" });
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export default function CalDavCalendarSetup() {
|
||||
});
|
||||
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [errorActionUrl, setErrorActionUrl] = useState("");
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-gray-200">
|
||||
@@ -49,6 +50,9 @@ export default function CalDavCalendarSetup() {
|
||||
const json = await res.json();
|
||||
if (!res.ok) {
|
||||
setErrorMessage(json?.message || t("something_went_wrong"));
|
||||
if (json.actionUrl) {
|
||||
setErrorActionUrl(json.actionUrl);
|
||||
}
|
||||
} else {
|
||||
router.push(json.url);
|
||||
}
|
||||
@@ -78,7 +82,24 @@ export default function CalDavCalendarSetup() {
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
{errorMessage && <Alert severity="error" title={errorMessage} className="my-4" />}
|
||||
{errorMessage && (
|
||||
<Alert
|
||||
severity="error"
|
||||
title={errorMessage}
|
||||
actions={
|
||||
errorActionUrl !== "" ? (
|
||||
<Button
|
||||
href={errorActionUrl}
|
||||
color="secondary"
|
||||
target="_blank"
|
||||
className="ml-5 w-32 !p-5">
|
||||
Go to Admin
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
className="my-4"
|
||||
/>
|
||||
)}
|
||||
<div className="mt-5 justify-end space-x-2 sm:mt-4 sm:flex">
|
||||
<Button type="button" color="secondary" onClick={() => router.back()}>
|
||||
{t("cancel")}
|
||||
|
||||
@@ -16,7 +16,7 @@ function ImpersonatingBanner() {
|
||||
variant="warning"
|
||||
actions={
|
||||
<a className="border-b border-b-black" href="/auth/logout">
|
||||
Click Here To stop
|
||||
{t("impersonating_stop_instructions")}
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user