2016-08-18 3 views
0

내 Angular 2 프로젝트에 auth0을 구현하려고하는데 잠금 위젯을 사용하지 않고 대신 자신의 로그인 양식과 버튼을 사용자 정의합니다. 소셜 로그인. 그래서 auth0 라이브러리를 사용하고 싶습니다. 그리고 번들로 묶어서 index.html로 가져 오지 마십시오.Auth0-js Angular 2 (RC5), Webpack 및 CLI

필자는 CLI를 사용하여 프로젝트 (1.0.0-beta.11-webpack.2)를 비계하고 NPM을 사용하여 auth0-js를 설치했습니다. 내 auth0 - js '폴더를 찾을 수 있습니다 내 node_modules, 지금은 그냥 어떻게 든 내 애플 리케이션에 연결해야합니다.

// login.component 

import { Component } from '@angular/core'; 
import * as Auth0 from "auth0-js"; 

@Component({ 
    selector: 'app-login', 
    templateUrl: 'login.component.html', 
    styleUrls: ['login.component.css'] 
}) 
export class LoginComponent implements OnInit { 

    auth0: any; 

    constructor() { 
    this.auth0 = new Auth0({ 
     domain: 'myDomain', 
     clientID: 'myClientId', 
     callbackURL: '{http://localhost:4000/}', // in dev-mode 
     callbackOnLocationHash: true 
    }); 
    } 

    loginWithGoogle(connection) { 
    this.auth0.login({ 
     connection: 'google-oauth2' 
    }); 
    } 
} 

는하지만 웹팩에서이 콘솔 메시지가 나타납니다 : [기본] ......... /node_modules/@types/auth0-js/index.d에서

오류가 발생했습니다. ts '는 모듈이 아닙니다.

입력이 작동하지 않지만 앱이 작동하는 것으로 보입니다. 내가 npm i @types/auth0-js --save과 함께 설치하고 예상대로 내 노드 모듈에 입력을 설치합니다.

타이핑에 문제가있는 것 같지만 무엇을해야합니까? 그리고 나 자신을 고칠 수있는 누군가인가요? 아니면 누군가 모듈화 된 타이핑을 업데이트 할 때까지 기다려야합니까?

감사합니다.

답변

0

저는 Auth0을 사용하지 않았습니다. 하지만이게 효과가 있다고 생각합니다.

    :

    main.ts

    import 'auth0-js/standalone'; 
    
    // Add this to test it. 
    var auth0 = new Auth0({ 
        domain:  'mine.auth0.com', 
        clientID:  'dsa7d77dsa7d7', 
        callbackURL: 'http://my-app.com/callback', 
        responseType: 'token' 
    }); 
    

    빠른 typings는 SRC/typings.d.ts

    declare var Auth0: any; 
    

    주위 typings을 할 수있는 더 좋은 방법을 작동

  • 있음 이것은 불행하게도 트릭을하지 않았다 당신의 tsconfig "types": ["auth0"]
+0

auth0의 typings이 https://www.npmjs.com/package/@types/auth0

  • 업데이트 스톨. 하지만 나는 실수를 한 것 같다 ... 응용 프로그램이 내 aproach와 완벽하게 작동합니다, 그것은 단지 누락 된 타이핑 일뿐입니다. – mottosson

  • 관련 문제