Azure B2C:函数应用程序中的 showBlockPage 自定义错误处理未正确显示

问题描述 投票:0回答:1

我在 Azure B2C 中遇到一个问题,即在 Azure Function App 中实现的自定义错误处理无法按预期工作。此功能应用程序设置为 API 连接器,专门用于登录/注册 (SI/SU) 用户流程中的“创建用户之前”事件。

在登录/注册过程中遇到特定错误情况时,Azure Function App 应触发带有自定义错误消息的 showBlockPage 响应。

尽管按照文档中的说明配置了 showBlockPage 响应,Azure B2C 仍显示默认错误消息(“处理您的请求时出现问题。请重试。”)而不是自定义错误消息。

为了排除和解决此问题,我查阅了各种资源,包括:

Microsoft 问答中的 Azure AD B2C 自定义连接器 showBlockPage 响应问题 关于 Azure AD B2C 自定义连接器 showBlockPage 响应的 Stack Overflow 讨论 Azure Docs 上有关 showBlockPage 响应的 GitHub 问题

azure-functions azure-ad-b2c
1个回答
0
投票
    const existingCompany = await getCompanyByName(connection, companyName).catch(error => {
        context.log(`Error in function getCompanyByName: ${error.message}`);
        throw error;
    });
    if (existingCompany) {
        context.log(`Company already exists ${JSON.stringify(existingCompany)}`);
        context.res = {
            status: 400,
            body: {
                version: API_VERSION,
                action: "ShowBlockPage",
                userMessage: "Your company already exists. Please contact your administrator to be added."
            }
        };
        return;
    }
© www.soinside.com 2019 - 2024. All rights reserved.