feat(infisical-pg): auth injection completed and validation in password router

This commit is contained in:
Akhil Mohan
2024-01-27 12:38:22 +05:30
parent fcfd6b3fb2
commit f3b37de3f3
196 changed files with 1871 additions and 624 deletions
@@ -17,7 +17,7 @@ import { useGetOrgPlanTable } from "@app/hooks/api";
export const CurrentPlanSection = () => {
const { currentOrg } = useOrganization();
const { data, isLoading } = useGetOrgPlanTable(currentOrg?._id ?? "");
const { data, isLoading } = useGetOrgPlanTable(currentOrg?.id ?? "");
const displayCell = (value: null | number | string | boolean) => {
if (value === null) return "-";
@@ -24,7 +24,7 @@ export const ManagePlansTable = ({ billingCycle }: Props) => {
const { currentOrg } = useOrganization();
const { subscription } = useSubscription();
const { data: tableData, isLoading: isTableDataLoading } = useGetOrgPlansTable({
organizationId: currentOrg?._id ?? "",
organizationId: currentOrg?.id ?? "",
billingCycle
});
const createCustomerPortalSession = useCreateCustomerPortalSession();
@@ -110,11 +110,11 @@ export const ManagePlansTable = ({ billingCycle }: Props) => {
<Td>
<Button
onClick={async () => {
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
if (tier !== 3) {
const { url } = await createCustomerPortalSession.mutateAsync(
currentOrg._id
currentOrg.id
);
window.location.href = url;
return;
@@ -22,7 +22,7 @@ import { ManagePlansModal } from "./ManagePlansModal";
export const PreviewSection = () => {
const { currentOrg } = useOrganization();
const { subscription } = useSubscription();
const { data, isLoading } = useGetOrgPlanBillingInfo(currentOrg?._id ?? "");
const { data, isLoading } = useGetOrgPlanBillingInfo(currentOrg?.id ?? "");
const getOrgTrialUrl = useGetOrgTrialUrl();
const createCustomerPortalSession = useCreateCustomerPortalSession();
@@ -58,7 +58,7 @@ export const PreviewSection = () => {
if (!subscription.has_used_trial) {
// direct user to start pro trial
const url = await getOrgTrialUrl.mutateAsync({
orgId: currentOrg._id,
orgId: currentOrg.id,
success_url: window.location.href
});
@@ -124,8 +124,8 @@ export const PreviewSection = () => {
<button
type="button"
onClick={async () => {
if (!currentOrg?._id) return;
const { url } = await createCustomerPortalSession.mutateAsync(currentOrg._id);
if (!currentOrg?.id) return;
const { url } = await createCustomerPortalSession.mutateAsync(currentOrg.id);
window.location.href = url;
}}
disabled={!isAllowed}
@@ -18,7 +18,7 @@ import {
export const LicensesSection = () => {
const { currentOrg } = useOrganization();
const { data, isLoading } = useGetOrgLicenses(currentOrg?._id ?? "");
const { data, isLoading } = useGetOrgLicenses(currentOrg?.id ?? "");
return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
@@ -35,7 +35,7 @@ export const LicensesSection = () => {
</THead>
<TBody>
{!isLoading && data && data?.length > 0 && data.map(({
_id,
id,
licenseKey,
isActivated,
createdAt,
@@ -44,7 +44,7 @@ export const LicensesSection = () => {
const formattedCreatedAt = new Date(createdAt).toISOString().split("T")[0];
const formattedExpiresAt = new Date(expiresAt).toISOString().split("T")[0];
return (
<Tr key={`license-${_id}`} className="h-10">
<Tr key={`license-${id}`} className="h-10">
<Td>{licenseKey}</Td>
<Td>{isActivated ? "Active" : "Inactive"}</Td>
<Td>{formattedCreatedAt}</Td>
@@ -25,7 +25,7 @@ export const OrgSSOSection = (): JSX.Element => {
const { currentOrg } = useOrganization();
const { subscription } = useSubscription();
const { createNotification } = useNotificationContext();
const { data, isLoading } = useGetSSOConfig(currentOrg?._id ?? "");
const { data, isLoading } = useGetSSOConfig(currentOrg?.id ?? "");
const { mutateAsync } = useUpdateSSOConfig();
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"upgradePlan",
@@ -36,10 +36,10 @@ export const OrgSSOSection = (): JSX.Element => {
const handleSamlSSOToggle = async (value: boolean) => {
try {
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
await mutateAsync({
organizationId: currentOrg?._id,
organizationId: currentOrg?.id,
isActive: value
});
@@ -63,7 +63,7 @@ export const OrgSSOSection = (): JSX.Element => {
// case: SAML SSO is not configured
// -> initialize empty SAML SSO configuration
await createMutateAsync({
organizationId: currentOrg._id,
organizationId: currentOrg.id,
authProvider: "okta-saml",
isActive: false,
entryPoint: "",
@@ -118,7 +118,7 @@ export const OrgSSOSection = (): JSX.Element => {
)}
<div className="mb-4">
<h3 className="text-mineshaft-400 text-sm">SSO identifier</h3>
<p className="text-gray-400 text-md">{data && data._id !== "" ? data._id : "-"}</p>
<p className="text-gray-400 text-md">{data && data.id !== "" ? data.id : "-"}</p>
</div>
<div className="mb-4">
<h3 className="text-mineshaft-400 text-sm">Type</h3>
@@ -57,7 +57,7 @@ export const SSOModal = ({
const { createNotification } = useNotificationContext();
const { mutateAsync: createMutateAsync, isLoading: createIsLoading } = useCreateSSOConfig();
const { mutateAsync: updateMutateAsync, isLoading: updateIsLoading } = useUpdateSSOConfig();
const { data } = useGetSSOConfig(currentOrg?._id ?? "");
const { data } = useGetSSOConfig(currentOrg?.id ?? "");
const {
control,
@@ -93,7 +93,7 @@ export const SSOModal = ({
if (!data) {
await createMutateAsync({
organizationId: currentOrg._id,
organizationId: currentOrg.id,
authProvider,
isActive: false,
entryPoint,
@@ -102,7 +102,7 @@ export const SSOModal = ({
});
} else {
await updateMutateAsync({
organizationId: currentOrg._id,
organizationId: currentOrg.id,
authProvider,
isActive: false,
entryPoint,
@@ -209,7 +209,7 @@ export const SSOModal = ({
<>
<div className="mb-4">
<h3 className="text-mineshaft-400 text-sm">{renderLabels(authProvider).acsUrl}</h3>
<p className="text-gray-400 text-md break-all">{`${window.origin}/api/v1/sso/saml2/${data._id}`}</p>
<p className="text-gray-400 text-md break-all">{`${window.origin}/api/v1/sso/saml2/${data.id}`}</p>
</div>
<div className="mb-4">
<h3 className="text-mineshaft-400 text-sm">{renderLabels(authProvider).entityId}</h3>
@@ -21,10 +21,10 @@ export const OrgDeleteSection = () => {
const handleDeleteOrgSubmit = async () => {
try {
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
await mutateAsync({
organizationId: currentOrg?._id
organizationId: currentOrg?.id
});
createNotification({
@@ -37,10 +37,10 @@ export const AddOrgIncidentContactModal = ({
const onFormSubmit = async ({ email }: TAddContactForm) => {
try {
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
await mutateAsync({
orgId: currentOrg._id,
orgId: currentOrg.id,
email
});
@@ -25,7 +25,7 @@ import { useDeleteIncidentContact, useGetOrgIncidentContact } from "@app/hooks/a
export const OrgIncidentContactsTable = () => {
const { createNotification } = useNotificationContext();
const { currentOrg } = useOrganization();
const { data: contacts, isLoading } = useGetOrgIncidentContact(currentOrg?._id ?? "");
const { data: contacts, isLoading } = useGetOrgIncidentContact(currentOrg?.id ?? "");
const [searchContact, setSearchContact] = useState("");
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
"removeContact",
@@ -37,9 +37,9 @@ export const OrgIncidentContactsTable = () => {
try {
const incidentContactEmail = (popUp?.removeContact?.data as { email: string })?.email;
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
await mutateAsync({
orgId: currentOrg._id,
orgId: currentOrg.id,
email: incidentContactEmail
});
@@ -31,10 +31,10 @@ export const OrgNameChangeSection = (): JSX.Element => {
const onFormSubmit = async ({ name }: FormData) => {
try {
if (!currentOrg?._id) return;
if (!currentOrg?.id) return;
if (name === "") return;
await mutateAsync({ orgId: currentOrg?._id, newOrgName: name });
await mutateAsync({ orgId: currentOrg?.id, newOrgName: name });
createNotification({
text: "Successfully renamed organization",
type: "success"
@@ -50,13 +50,13 @@ export const APIKeyV2Table = ({
data &&
data.length > 0 &&
data.map(({
_id,
id,
name,
lastUsed,
createdAt
}) => {
return (
<Tr className="h-10" key={`api-key-v2-${_id}`}>
<Tr className="h-10" key={`api-key-v2-${id}`}>
<Td>{name}</Td>
<Td>{lastUsed ? format(new Date(lastUsed), "yyyy-MM-dd") : "-"}</Td>
<Td>{format(new Date(createdAt), "yyyy-MM-dd")}</Td>
@@ -64,7 +64,7 @@ export const APIKeyV2Table = ({
<IconButton
onClick={async () => {
handlePopUpOpen("apiKeyV2", {
apiKeyDataId: _id,
apiKeyDataId: id,
name
});
}}
@@ -78,7 +78,7 @@ export const APIKeyV2Table = ({
<IconButton
onClick={() => {
handlePopUpOpen("deleteAPIKeyV2", {
apiKeyDataId: _id
apiKeyDataId: id
});
}}
size="lg"