2016-01-26 135 views
0

我正在使用来自www.auth0.com和AngularJS的auth0-lock。 我能够通过一些参数如在SDK:https://auth0.com/docs/libraries/lock/customization#connections-array-使用auth0-angular自定义auth0-lock

 auth.signin({ 
      disableSignupAction: true, 
      socialBigButtons: true, 
      //these lines don't work 
      //no changes (username, password appears) 
      //connection: 'windows-live' 
      //this line returns 'No valid connection found' 
      //connections: 'windows-live' 
      //this line returns 'No valid connection found' 
      //connections: ['windows-live'] 
      //this line doesn't change anything 
      //connection: ['windows-live'] 

     } 

,但我不能够通过连接(从SDK非角版本)

lock.show({ 
connections: ['twitter', 'facebook', 'linkedin'] 
}); 

这两个参数的连接或连接的别工作。

我的问题是,如果我不指定连接(连接)用户名和密码将出现。根据SDK,我需要对其进行硬编码,以隐藏这些字段。 由于SDK是为JS而不是AngularJS编写的,因此我似乎遇到了传递数组或参数的问题。 任何想法?

回答

1

你想发送带有连接参数数组:就像你有

connections: ['windows-live'] 

,而不是字符串:

connections: 'windows-live' 
+0

我没有提到这一点,但它不能正常工作。 结果与:“无法找到有效连接” 我已更新问题。 –

1

是否启用了社会在仪表板? Enable Social

0

该文档似乎对此如此。如果您使用//cdn.auth0.com/js/lock-8.js,它应该在前面的响应中看到,并遵循示例https://github.com/auth0/auth0-angular/tree/master/examples

我与连接摔跤:&连接几个小时试图让一些自定义连接工作。

作为一个基地,您可以启用Auth0社交服务提供商中的各种提供商,确保它们切换为绿色。尽可能简单地开始并从那里展开。

auth.signin({ 
     scope: 'openid name email' 

的index.html

<script type="text/javascript" src="//cdn.auth0.com/js/lock-8.js"></script> 
<!--script src="//cdn.auth0.com/w2/auth0-6.7.js"></script--> 
<script type="text/javascript" src="https://cdn.auth0.com/w2/auth0-angular-4.js"></script> 
<script src="./lib/a0-angular-storage/dist/angular-storage.js"></script> 
<script src="./lib/angular-jwt/dist/angular-jwt.js"></script> 

登录CTRL

.controller('LoginCtrl', 
    function onLoginSuccess(profile, token) { 
     console.log("login ok"); 
    } 

    function onLoginFailed() { 
     console.log("failed login"); 
    } 

    auth.signin({ 
     scope: 'openid name email' 
    }, onLoginSuccess, onLoginFailed); 
} 

配置块

.config(function($stateProvider, $urlRouterProvider, authProvider, 
      jwtInterceptorProvider, $httpProvider) { 

authProvider.init({ 
    domain: '', 
    clientID: '', 
    loginState: 'login', 
    loginUrl: true 
}); 


    authProvider.on('loginSuccess', function($location, profilePromise, idToken, store) { 
     profilePromise.then(function(profile) { 
      console.log(JSON.stringify(profile));