2017-09-13 81 views
0

我正在使用ASP.Net Core創建網站,並使用Azure AD B2C保護它。Azure Active Directory註冊重定向到登錄

我已經實施登錄,它都工作正常,但現在我試圖安裝註冊,它似乎並沒有工作。

我的網站設置基於this sample

在那個例子中,他們沒有使用註冊策略,因爲他們使用共享註冊和登錄策略(我不希望這樣),但他們確實使用了編輯配置文件並重置密碼策略,API方法可以是見於SessionController

我想實現同樣的方式我註冊端點像這樣:

var properties = new AuthenticationProperties() { RedirectUri = "/" }; 
properties.Items[AzureAdB2COptions.PolicyAuthenticationProperty] = AzureAdB2COptions.SignUpPolicyId; 
await HttpContext.Authentication.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties, ChallengeBehavior.Unauthorized); 

然而,當我去這裏我簡單地重定向到登錄頁面,而不是在註冊頁面。

註冊政策和一般B2C目錄設置正確,因爲我在另一個網站上使用它沒有問題。

任何人都可以建議可能造成這種情況嗎?

回答

1

在我OnRedirectToIdentityProvider方法我有:

context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.Replace(defaultPolicy, policy); 

由於IssuerAddress這裏是它不是查找和更改政策小寫。

我把它更新爲:

context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.ToLower().Replace(defaultPolicy.ToLower(), policy.ToLower()); 

由於是在latest version of the sample

+0

嘿湯姆,你能不能舉報您的問題如回答? – Saca

+0

@Saca是的,一旦它允許我,我會自己做:) – Tom