+14








156f3e5de2
* feat: use the trans hook * fix: hide AdminPasswordBanner * fix: translation * fix: style and use validation * fix: layout * fix: use trans keys * fix: replace number with placeholder * feat: add alert banner * fix: use the correct password length * fix: metadata not saved while creating a booking. (#6866) * feat: add metadata to booking creation * fix: bug * Beginning of Strict CSP Compliance (#6841) * Add CSP Support and enable it initially for Login page * Update README * Make sure that CSP is not enabled if CSP_POLICY isnt set * Add a new value for x-csp header that tells if instance has opted-in to CSP or not * Add more src to CSP * Fix typo in header name * Remove duplicate headers fn * Add https://eu.ui-avatars.com/api/ * Add CSP_POLICY to env.example * v2.5.10 * fix: add req.headers (#6921) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * add-console-vars (#6929) * Admin Wizard Choose License (#6574) * Implementation * i18n * More i18n * extracted i18n, needs api to get most recent price, added hint: update later * Fixing i18n var * Fix booking filters not working for admin (#6576) * fix: react-select overflow issue in some modals. (#6587) * feat: add a disable overflow prop * feat: use the disable overflow prop * Tailwind Merge (#6596) * Tailwind Merge * Fix merge classNames * [CAL-808] /availability/single - UI issue on buttons beside time inputs (#6561) * [CAL-808] /availability/single - UI issue on buttons beside time inputs * Update apps/web/public/static/locales/en/common.json * Update packages/features/schedules/components/Schedule.tsx * create new translation for tooltip Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> * Bye bye submodules (#6585) * WIP * Uses ssh instead * Update .gitignore * Update .gitignore * Update Makefile * Update git-setup.sh * Update git-setup.sh * Replaced Makefile with bash script * Update package.json * fix: show button on empty string (#6601) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: add delete in dropdown (#6599) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Update README.md * Update README.md * Changed a neutral- classes to gray (#6603) * Changed a neutral- classes to gray * Changed all border-1 to border * Update package.json * Test fixes * Yarn lock fixes * Fix string equality check in git-setup.sh * [CAL-811] Avatar icon not redirecting user back to the main page (#6586) * Remove cursor-pointer, remove old Avatar* files * Fixed styling for checkedSelect + some cleanup Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> * Harsh/add member invite (#6598) Co-authored-by: Guest <guest@pop-os.localdomain> Co-authored-by: root <harsh.singh@gocomet.com> * Regenerated lockfile without upgrade (#6610) * fix: remove annoying outline when <Button /> clicked (#6537) * fix: remove annoying outline when <Button /> clicked * Delete yarn.lock * remove 1 on 1 icon (#6609) * removed 1-on-1 badge * changed user to users for group events * fix: case-sensitivity in apps path (#6552) * fix: lowercase slug * fix: make fallback blocking * Fix FAB (#6611) * feat: add LocationSelect component (#6571) * feat: add LocationSelect component Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: type error Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * chore: type error Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Update booking filters design (#6543) * Update booking filters * Add filter on YOUR bookings * Fix pending members showing up in list * Reduce the avatar size to 'sm' for now * Bugfix/dropdown menu trigger as child remove class names (#6614) * Fix UsernameTextfield to take right height * Remove className side-effect * Incorrect resolution version fixed * Converted mobile DropdownMenuTrigger styles into Button * v2.5.3 * fix: use items-center (#6618) * fix tooltip and modal stacking issues (#6491) * fix tooltip and modal stacking issues * use z-index in larger screens and less Co-authored-by: Alex van Andel <me@alexvanandel.com> * Temporary fix (#6626) * Fix Ga4 tracking (#6630) * generic <UpgradeScreen> component (#6594) * first attempt of <UpgradeScreen> * changes to icons * reverted changes back to initial state, needs fix: teams not showing * WIP * Fix weird reactnode error * Fix loading text * added upgradeTip to routing forms * icon colors * create and use hook to check if user has team plan * use useTeamPlan for upgradeTeamsBadge * replace huge svg with compressed jpeg * responsive fixes * Update packages/ui/components/badge/UpgradeTeamsBadge.tsx Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> * Give team plan features to E2E tests * Allow option to make a user part of team int ests * Remove flash of paywall for team user * Add team user for typeform tests as well Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> * Removing env var to rely on db * Restoring i18n keys, set loading moved * Fixing tailwind-preset glob * Wizard width fix for md+ screens * Converting licenses options to radix radio * Applying feedback + other tweaks * Reverting this, not this PR related * Unneeded code removal * Reverting unneeded style change * Applying feedback * Removing licenseType * Upgrades typescript * Update yarn lock * Typings * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713) * Adds deployment settings to DB (#6706) * WIP * Adds DeploymentTheme * Add missing migrations * Adds client extensions for deployment * Cleanup * Delete migration.sql * Relying on both, env var and new model * Restoring env example doc for backward compat * Maximum call stack size exceeded fix? * Revert upgrade * Update index.ts * Delete index.ts * Not exposing license key, fixed radio behavior * Covering undefined env var * Self contained checkLicense * Feedback * Moar feedback * Feedback * Feedback * Feedback * Cleanup --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com> Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com> Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com> Co-authored-by: Guest <guest@pop-os.localdomain> Co-authored-by: root <harsh.singh@gocomet.com> Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com> Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> * added two new tips (#6915) * [CAL-488] Timezone selection has a weird double dropdown (#6851) Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> * fix: color and line height of icon (#6913) * fix: use destination calendar email (#6886) * fix: use destination calendar email to display correct primary email Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: simplify logic Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: dropdown title in bookings page (#6924) * fixes the broken max size of members on teams page (#6926) * fix: display provider name instead of url (#6914) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: add sortByLabel (#6797) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Email Variables Bug (#6943) * Remove _subject translations for zh-CN, needs retranslation * minor timezone-select improvements (#6944) * fixed timezone select positioning and hover * fixed timezone select positioning and hover * Give trackingId a default value because if user doesnt interact with trackingId input it is not set (#6945) * Block /auth/:path, nothing else. (#6949) * Block /auth/:path, nothing else. * Also add /signup * fix start icon in button (#6950) Co-authored-by: CarinaWolli <wollencarina@gmail.com> * Fixes localisation of {EVENT_DATE} in workflows (#6907) * translate {EVENT_DATE} variable to correct language * fix locale for cron schedule reminder emails/sms * fix type error * add missing locale to attendees * fix type error * code clean up * revert last commit * using Intl for date translations --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> * Allow account linking for Google and SAML providers (#6874) * allow account linking for self-hosted instances, both Google and SAML are verified emails * allow account linking for Google and SSO if emails match with existing username/password account * Tweaked find user by email since we now have multiple providers (other than credentials provider) * feat/payment-service-6438-cal-767 (#6677) * WIP paymentService * Changes for payment Service * Fix for stripe payment flow * Remove logs/comments * Refactored refund for stripe app * Move stripe handlePayment to own lib * Move stripe delete payments to paymentService * lint fix * Change handleRefundError as generic function * remove log * remove logs * remove logs * Return stripe default export to lib/server * Fixing types * Fix types * Upgrades typescript * Update yarn lock * Typings * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713) * Adds deployment settings to DB (#6706) * WIP * Adds DeploymentTheme * Add missing migrations * Adds client extensions for deployment * Cleanup * Revert "lint fix" This reverts commit e1a2e4a357e58e6673c47399888ae2e00d1351a6. * Add validation * Revert changes removed in force push * Removing abstract class and just leaving interface implementation * Fix types for handlePayments * Fix payment test appStore import * Fix stripe metadata in event type * Move migration to separate PR * Revert "Move migration to separate PR" This reverts commit 48aa64e0724a522d3cc2fefaaaee5792ee9cd9e6. * Update packages/prisma/migrations/20230125175109_remove_type_from_payment_and_add_app_relationship/migration.sql Co-authored-by: Omar López <zomars@me.com> --------- Co-authored-by: zomars <zomars@me.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> * Small UI fixes for seats & destination calendars (#6859) * Do not add former time for events on seats * Default display destination calendar * Add seats badge to event type item * Add string * Actively watch seats enabled option for requires confirmation * Only show former time when there is a rescheduleUid * fix: use typedquery hook in duplicate dialog (#6730) * fix: use typedquery hook in duplicate dialog Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Update packages/features/eventtypes/components/DuplicateDialog.tsx --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: Omar López <zomars@me.com> * Fixing admin wizard step done (#6954) * Feature/maintenance mode (#6930) * Implement maintenance mode with Vercel Edge Config * Error log is spam during development/ added \n in .env.example * Exclude _next, /api for /maintenance page * Re-instate previous config * rtl: begone * Added note to explain why /auth/login covers the maintenance page. --------- Co-authored-by: Omar López <zomars@me.com> * Update package.json * I18N Caching (#6823) * Caching Logic Changes Enabled this function to change its cache value based on incoming paths value * Invalidate I18N Cache Invalidating the I18N cache when a user saves changes to their General settings * Removes deprecated useLocale location * Overriding the default getSchedule cache to have a revalidation time of 1 second * Update apps/web/pages/api/trpc/[trpc].ts * Updated cache values to match the comment --------- Co-authored-by: zomars <zomars@me.com> --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: alannnc <alannnc@gmail.com> Co-authored-by: Leo Giovanetti <hello@leog.me> Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com> Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com> Co-authored-by: Guest <guest@pop-os.localdomain> Co-authored-by: root <harsh.singh@gocomet.com> Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com> Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Joe Shajan <joeshajan1551@gmail.com> Co-authored-by: Ben Hybert <53020786+Hybes@users.noreply.github.com> Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Aaron Presley <155617+AaronPresley@users.noreply.github.com>
223 lines
7.9 KiB
TypeScript
223 lines
7.9 KiB
TypeScript
import { IdentityProvider } from "@prisma/client";
|
|
import { GetServerSidePropsContext } from "next";
|
|
import { signOut, useSession } from "next-auth/react";
|
|
import { useForm } from "react-hook-form";
|
|
|
|
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
|
|
import { identityProviderNameMap } from "@calcom/lib/auth";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { userMetadata } from "@calcom/prisma/zod-utils";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import { Alert, Button, Form, Meta, PasswordField, Select, SettingsToggle, showToast } from "@calcom/ui";
|
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
type ChangePasswordSessionFormValues = {
|
|
oldPassword: string;
|
|
newPassword: string;
|
|
sessionTimeout?: number;
|
|
apiError: string;
|
|
};
|
|
|
|
const PasswordView = () => {
|
|
const { data } = useSession();
|
|
const { t } = useLocale();
|
|
const utils = trpc.useContext();
|
|
const { data: user } = trpc.viewer.me.useQuery();
|
|
const metadata = userMetadata.parse(user?.metadata);
|
|
|
|
const sessionMutation = trpc.viewer.updateProfile.useMutation({
|
|
onSuccess: () => {
|
|
showToast(t("session_timeout_changed"), "success");
|
|
formMethods.reset(formMethods.getValues());
|
|
},
|
|
onSettled: () => {
|
|
utils.viewer.me.invalidate();
|
|
},
|
|
onMutate: async ({ metadata }) => {
|
|
await utils.viewer.me.cancel();
|
|
const previousValue = utils.viewer.me.getData();
|
|
const previousMetadata = userMetadata.parse(previousValue?.metadata);
|
|
|
|
if (previousValue && metadata?.sessionTimeout) {
|
|
utils.viewer.me.setData(undefined, {
|
|
...previousValue,
|
|
metadata: { ...previousMetadata, sessionTimeout: metadata?.sessionTimeout },
|
|
});
|
|
}
|
|
return { previousValue };
|
|
},
|
|
onError: (error, _, context) => {
|
|
if (context?.previousValue) {
|
|
utils.viewer.me.setData(undefined, context.previousValue);
|
|
}
|
|
showToast(`${t("session_timeout_change_error")}, ${error.message}`, "error");
|
|
},
|
|
});
|
|
const passwordMutation = trpc.viewer.auth.changePassword.useMutation({
|
|
onSuccess: () => {
|
|
showToast(t("password_has_been_changed"), "success");
|
|
formMethods.resetField("oldPassword");
|
|
formMethods.resetField("newPassword");
|
|
|
|
if (data?.user.role === "INACTIVE_ADMIN") {
|
|
/*
|
|
AdminPasswordBanner component relies on the role returned from the session.
|
|
Next-Auth doesn't provide a way to revalidate the session cookie,
|
|
so this a workaround to hide the banner after updating the password.
|
|
discussion: https://github.com/nextauthjs/next-auth/discussions/4229
|
|
*/
|
|
signOut({ callbackUrl: "/auth/login" });
|
|
}
|
|
},
|
|
onError: (error) => {
|
|
showToast(`${t("error_updating_password")}, ${t(error.message)}`, "error");
|
|
|
|
formMethods.setError("apiError", {
|
|
message: t(error.message),
|
|
type: "custom",
|
|
});
|
|
},
|
|
});
|
|
|
|
const formMethods = useForm<ChangePasswordSessionFormValues>({
|
|
defaultValues: {
|
|
oldPassword: "",
|
|
newPassword: "",
|
|
sessionTimeout: metadata?.sessionTimeout,
|
|
},
|
|
});
|
|
|
|
const sessionTimeoutWatch = formMethods.watch("sessionTimeout");
|
|
|
|
const handleSubmit = (values: ChangePasswordSessionFormValues) => {
|
|
const { oldPassword, newPassword, sessionTimeout } = values;
|
|
if (oldPassword && newPassword) {
|
|
passwordMutation.mutate({ oldPassword, newPassword });
|
|
}
|
|
if (metadata?.sessionTimeout !== sessionTimeout) {
|
|
sessionMutation.mutate({ metadata: { ...metadata, sessionTimeout } });
|
|
}
|
|
};
|
|
|
|
const timeoutOptions = [5, 10, 15].map((mins) => ({
|
|
label: t("multiple_duration_mins", { count: mins }),
|
|
value: mins,
|
|
}));
|
|
|
|
const isDisabled = formMethods.formState.isSubmitting || !formMethods.formState.isDirty;
|
|
|
|
const passwordMinLength = data?.user.role === "USER" ? 7 : 15;
|
|
const isUser = data?.user.role === "USER";
|
|
return (
|
|
<>
|
|
<Meta title={t("password")} description={t("password_description")} />
|
|
{user && user.identityProvider !== IdentityProvider.CAL ? (
|
|
<div>
|
|
<div className="mt-6">
|
|
<h2 className="font-cal text-lg font-medium leading-6 text-gray-900">
|
|
{t("account_managed_by_identity_provider", {
|
|
provider: identityProviderNameMap[user.identityProvider],
|
|
})}
|
|
</h2>
|
|
</div>
|
|
<p className="mt-1 text-sm text-gray-500">
|
|
{t("account_managed_by_identity_provider_description", {
|
|
provider: identityProviderNameMap[user.identityProvider],
|
|
})}
|
|
</p>
|
|
</div>
|
|
) : (
|
|
<Form form={formMethods} handleSubmit={handleSubmit}>
|
|
{formMethods.formState.errors.apiError && (
|
|
<div className="pb-6">
|
|
<Alert severity="error" message={formMethods.formState.errors.apiError?.message} />
|
|
</div>
|
|
)}
|
|
|
|
<div className="max-w-[38rem] sm:grid sm:grid-cols-2 sm:gap-x-4">
|
|
<div>
|
|
<PasswordField {...formMethods.register("oldPassword")} label={t("old_password")} />
|
|
</div>
|
|
<div>
|
|
<PasswordField
|
|
{...formMethods.register("newPassword", {
|
|
minLength: {
|
|
message: t(isUser ? "password_hint_min" : "password_hint_admin_min"),
|
|
value: passwordMinLength,
|
|
},
|
|
pattern: {
|
|
message: "Should contain a number, uppercase and lowercase letters",
|
|
value: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).*$/gm,
|
|
},
|
|
})}
|
|
label={t("new_password")}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<p className="mt-4 max-w-[38rem] text-sm text-gray-600">
|
|
{t("invalid_password_hint", { passwordLength: passwordMinLength })}
|
|
</p>
|
|
<div className="mt-8 border-t border-gray-200 py-8">
|
|
<SettingsToggle
|
|
title={t("session_timeout")}
|
|
description={t("session_timeout_description")}
|
|
checked={sessionTimeoutWatch !== undefined}
|
|
data-testid="session-check"
|
|
onCheckedChange={(e) => {
|
|
if (!e) {
|
|
formMethods.setValue("sessionTimeout", undefined, { shouldDirty: true });
|
|
} else {
|
|
formMethods.setValue("sessionTimeout", 10, { shouldDirty: true });
|
|
}
|
|
}}
|
|
/>
|
|
{sessionTimeoutWatch && (
|
|
<div className="mt-4 text-sm">
|
|
<div className="flex items-center">
|
|
<p className="text-neutral-900 ltr:mr-2 rtl:ml-2">{t("session_timeout_after")}</p>
|
|
<Select
|
|
options={timeoutOptions}
|
|
defaultValue={
|
|
metadata?.sessionTimeout
|
|
? timeoutOptions.find((tmo) => tmo.value === metadata.sessionTimeout)
|
|
: timeoutOptions[1]
|
|
}
|
|
isSearchable={false}
|
|
className="block h-[36px] !w-auto min-w-0 flex-none rounded-md text-sm"
|
|
onChange={(event) => {
|
|
formMethods.setValue("sessionTimeout", event?.value, { shouldDirty: true });
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
{/* TODO: Why is this Form not submitting? Hacky fix but works */}
|
|
<Button
|
|
color="primary"
|
|
className="mt-8"
|
|
type="submit"
|
|
disabled={isDisabled || passwordMutation.isLoading || sessionMutation.isLoading}>
|
|
{t("update")}
|
|
</Button>
|
|
</Form>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
PasswordView.getLayout = getLayout;
|
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
const ssr = await ssrInit(context);
|
|
|
|
return {
|
|
props: {
|
|
trpcState: ssr.dehydrate(),
|
|
},
|
|
};
|
|
};
|
|
|
|
export default PasswordView;
|