Revert "security: enforce authenticated CRM contact ownership"
This reverts commit e13700ab65.
This commit is contained in:
@@ -14,8 +14,8 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import NextAuth from "next-auth";
|
||||
import EmailProvider from "../../../lib/auth/email-provider";
|
||||
import { resolveCrmLocale } from "../../../lib/auth/resolveCrmLocale";
|
||||
import { consoleLogger, redactSensitive } from "../../../actions/core/logger";
|
||||
import { getPortalLogin } from "../../../actions/services/accountService";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -53,6 +53,8 @@ const createVerificationTokenSynchronizationAdapter = (
|
||||
};
|
||||
};
|
||||
|
||||
const WELSH_LANGUAGE_CODE = 846040000;
|
||||
|
||||
const authDiagnostic = (event, metadata = {}) => {
|
||||
try {
|
||||
const safeMeta = JSON.parse(JSON.stringify(metadata));
|
||||
@@ -82,6 +84,29 @@ const appendParamsAndPathToNewUrl = (fromUrl, toUrl) => {
|
||||
}
|
||||
};
|
||||
|
||||
const resolveCrmLocale = async (email) => {
|
||||
if (!email) return null;
|
||||
|
||||
try {
|
||||
const portalUserObj = await getPortalLogin(email);
|
||||
const preferredLanguage =
|
||||
portalUserObj?.value?.[0]?.pinswg_preferredlanguage;
|
||||
|
||||
if (preferredLanguage === WELSH_LANGUAGE_CODE) {
|
||||
return "cy";
|
||||
}
|
||||
|
||||
if (preferredLanguage != null) {
|
||||
return "en";
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveEffectiveLocale = async (req, email) => {
|
||||
const crmLocale = await resolveCrmLocale(email);
|
||||
if (crmLocale) {
|
||||
|
||||
Reference in New Issue
Block a user