简体   繁体   English

如何让用户在Azure AD B2C注册后返回登录页面?

[英]How to make user return on login page after sign-up in Azure AD B2C?

When a user is signing-up in the system, he is automatically redirected to our application as a signed in user.当用户在系统中注册时,他将作为已登录用户自动重定向到我们的应用程序。 I would like that after the sign-up, he is redirected to the signing page.我希望在注册后,他被重定向到签名页面。 I want this behavior since users need to be approved by an admin before having access to the system.我想要这种行为,因为用户在访问系统之前需要得到管理员的批准。 I use custom policies.我使用自定义策略。

I tried to use the "SM-Noop" session manager but it is not working.我尝试使用“SM-Noop”session 管理器,但它不起作用。 There is my code:有我的代码:

<!--Local account sign-up page-->
    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="email" PartnerClaimType="Verified.Email" Required="true" />
        <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
        <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
        <OutputClaim ClaimTypeReferenceId="mobile" />
        <OutputClaim ClaimTypeReferenceId="extension_phoneExtension" />
        <OutputClaim ClaimTypeReferenceId="givenName" />
        <OutputClaim ClaimTypeReferenceId="surName" />
        <OutputClaim ClaimTypeReferenceId="extension_company" />
        <OutputClaim ClaimTypeReferenceId="streetAddress" />
        <OutputClaim ClaimTypeReferenceId="city" />
        <OutputClaim ClaimTypeReferenceId="state" />
        <OutputClaim ClaimTypeReferenceId="country" />
        <OutputClaim ClaimTypeReferenceId="postalcode" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

Edit1: The solution seems to be to add orchestrationSteps. Edit1:解决方案似乎是添加 orchestrationSteps。 There is a link doing that but with a password reset: www.stackoverflow.com/a/62878136 In my case, it is not working since I can't add two CombinedSignInAndSignUp in the same userJourney so it crashes.有一个链接这样做但密码重置: www.stackoverflow.com/a/62878136在我的情况下,它不起作用,因为我无法在同一个 userJourney 中添加两个 CombinedSignInAndSignUp,所以它崩溃了。 Any other idea?还有其他想法吗?

Edit2: There is my policy for the SignUpSignIn: Edit2:我的 SignUpSignIn 政策是:

 <UserJourney Id="SignUpOrSignIn">
  <OrchestrationSteps>

    <OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
      <ClaimsProviderSelections>
        <ClaimsProviderSelection ValidationClaimsExchangeId="LocalAccountSigninEmailExchange" />
      </ClaimsProviderSelections>
      <ClaimsExchanges>
        <ClaimsExchange Id="LocalAccountSigninEmailExchange" TechnicalProfileReferenceId="SelfAsserted-LocalAccountSignin-Email" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <Preconditions>
        <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
          <Value>objectId</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <!-- This step reads any user attributes that we may not have received when in the token. -->
    <OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>

    <OrchestrationStep Order="4" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />

  </OrchestrationSteps>
  <ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>

Still trying to figure out what to put in Order="5" and so on in my TrustFrameworkExtensions.xml仍在尝试找出在我的 TrustFrameworkExtensions.xml 中放入 Order="5" 等的内容

Below are the configuration you can do:以下是您可以执行的配置:

Claim Type (To Print the Message from B2C Side)声明类型(从 B2C 端打印消息)

<ClaimType Id="userMessage">
        <DisplayName></DisplayName>
        <DataType>string</DataType>
        <UserInputType>Paragraph</UserInputType>
    </ClaimType>

ClaimsTransformation声明转换

<ClaimsTransformation Id="GetUserMessage" TransformationMethod="CreateStringClaim">
        <InputParameters>
            <InputParameter Id="value" DataType="string" Value="[![Your Account has been successfully created. To continue click on the sign-in link below.][1]][1]" />
        </InputParameters>
        <OutputClaims>
            <OutputClaim ClaimTypeReferenceId="userMessage" TransformationClaimType="createdClaim" />
        </OutputClaims>
    </ClaimsTransformation>

Technical Profile:技术简介:

<TechnicalProfile Id="SelfAsserted-UserMessage">
      <DisplayName>After Registration</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="ContentDefinitionReferenceId">api.selfasserted</Item>
        <!--Demo: hide the continue and cancel buttons -->
        <Item Key="setting.showContinueButton">false</Item>
        <Item Key="setting.showCancelButton">false</Item>
      </Metadata>
      <InputClaimsTransformations>
        <InputClaimsTransformation ReferenceId="GetUserMessage" />
      </InputClaimsTransformations>
      <InputClaims>
         <InputClaim ClaimTypeReferenceId="userMessage" />
      </InputClaims>
      <OutputClaims>
        <!--Demo: Show the paragraph claim with the message to the user -->
        <OutputClaim ClaimTypeReferenceId="userMessage" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

User Journey:用户旅程:

<OrchestrationStep Order="3" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="4" Type="ClaimsExchange">
    <Preconditions>
        <Precondition Type="ClaimsExist" ExecuteActionsIf="false">
          <Value>extension_isApproved</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
         <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
          <Value>extension_isApproved</Value>
          <Value>True</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="SendClaims" TechnicalProfileReferenceId="SelfAsserted-UserMessage" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="5" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
    </OrchestrationSteps>

Note : Make Sure in the " AAD-UserReadUsingObjectId " you add the below claim:注意:确保在“ AAD-UserReadUsingObjectId ”中添加以下声明:

<OutputClaim ClaimTypeReferenceId="extension_isApproved" />

Also in the " SelfAsserted-UserMessage " Profile, in the content definition you can have custom page which will have the link of your Login Page.同样在“ SelfAsserted-UserMessage ”配置文件中,在内容定义中,您可以拥有自定义页面,该页面将包含您的登录页面的链接。 Below is the screenshot of how it appears by default.以下是默认显示方式的屏幕截图。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM