2017-01-19 7 views
1

auth0を使用してユーザーの詳細を維持しています。私はThis articleに従っています。auth0の接続が見つかりません

デフォルトのロック画面を使用しているプロジェクトをダウンロードしましたが、正常に動作しています。ユーザーとログイン、ログアウトを作成できます。

カスタムログインビューで試してみると、自分の資格情報でログインしようとすると「接続が見つかりません」というエラーが表示されます。

私は確信していますが、ここでどの接続を渡す必要がありますか。

以下、上記の記事から貼り付けたコードです。以下は

[HttpPost] 
     public async Task<ActionResult> Login(LoginViewModel vm, string returnUrl = null) 
     { 
      if (ModelState.IsValid) 
      { 
       try 
       { 
        AuthenticationApiClient client = 
         new AuthenticationApiClient(
          new Uri($"https://{ConfigurationManager.AppSettings["auth0:Domain"]}/")); 

        var result = await client.AuthenticateAsync(new AuthenticationRequest 
        { 
         ClientId = ConfigurationManager.AppSettings["auth0:ClientId"], 
         Scope = "openid", 
         Connection = "Database-Connection", // Specify the correct name of your DB connection 
         Username = vm.EmailAddress, 
         Password = vm.Password 
        }); 

        // Get user info from token 
        var user = await client.GetTokenInfoAsync(result.IdToken); 

        // Create claims principal 
        var claimsIdentity = new ClaimsIdentity(new[] 
        { 
        new Claim(ClaimTypes.NameIdentifier, user.UserId), 
        new Claim(ClaimTypes.Name, user.FullName ?? user.Email), 
        new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string") 
       }, DefaultAuthenticationTypes.ApplicationCookie); 

        // Sign user into cookie middleware 
        AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = false }, claimsIdentity); 

        return RedirectToLocal(returnUrl); 
       } 
       catch (Exception e) 
       { 
        ModelState.AddModelError("", e.Message); 
       } 
      } 

      return View(vm); 
     } 

あなたが確認する必要があり

Connection name

答えて

2

、私も画像の下としてAuthenticationRequestに正しい接続名を渡しています、

Error Details

私は取得していますエラーですAuthenticationRequestインスタンスで指定されているConnectionの名前がsをAuthenticateAsyncにAuth0アカウント内の既存のデータベース接続にマップします。

具体的には、現在の接続の名前として"Database-Connection"を渡しているとあなたがその名前を持ついずれかの接続が存在することを確認したり、コードを変更する必要があります。

new AuthenticationRequest { 
    // ... 
    Connection = "Database-Connection", 
    Username = vm.EmailAddress, 
    Password = vm.Password 
} 
+0

[OK]を、私はデータベース名を渡しています"Auth0AuthenticationDB"と私のログインを許可していますが、今私にトークン情報を与えていません。私はロック画面を使用していたときにトークンを取得していました –

+0

働いています..私はログインアクションでclaimsIdentityにトークンを渡します –