当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript angular2-social-login.AuthService类代码示例

本文整理汇总了TypeScript中angular2-social-login.AuthService的典型用法代码示例。如果您正苦于以下问题:TypeScript AuthService类的具体用法?TypeScript AuthService怎么用?TypeScript AuthService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AuthService类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: callback

  /**
   * Authenticate the user in google
   */
  gauth(callback) {
    this._auth.login('google').subscribe((data) => {
      let headers = new Headers();
      headers.append('Content-Type', 'application/json');

      this.http.post('/api/auth/login', data, { headers: headers })
        .map(res => res.json())
        .subscribe(r => {
          if (r.success) {
            let profile = {
              email: data['email'],
              image: data['image'],
              name: data['name'],
              id: r.id
            };
            // Save profile and token to local storage
            localStorage.setItem('token', data['token']);
            localStorage.setItem('profile', JSON.stringify(profile));
            return callback(null, profile);
          } else {
            return callback(r.message);
          }
        });
    });
  }
开发者ID:gabuladze,项目名称:vout,代码行数:28,代码来源:login.service.ts

示例2:

  	logout(){
	    this._auth.logout().subscribe(
	      (data)=>{
	         this.cookieService.removeAll();
    		this._router.navigate(['/login']);
	        console.log(data);this.user=null;
	        
	      }
	    )
	}
开发者ID:Rishabh6211,项目名称:chat-app-angualr2,代码行数:10,代码来源:shared.service.ts

示例3: logout

    logout(): void {
        // clear token remove user from local storage to log user out
        this.token = null;
        localStorage.removeItem('currentUser');

        if (localStorage.getItem('_login_provider')) {
            this._auth.logout().subscribe(
                (data) => {
                }
            )
        }


    }
开发者ID:arielcessario,项目名称:bayres-web,代码行数:14,代码来源:authentication.service.ts

示例4: logout

  /**
   * Log out the user
   */
  logout(callback) {
    let error: any;
    let instance = JSON.parse(localStorage.getItem('instance'));

    this._auth.logout().subscribe((data) => {
      if (data) {
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        let email = this.getProfile().email;
        this.http.post('/api/auth/logout', email, { headers: headers })
          .map(res => res.json())
          .subscribe(data => {
            if (data.success) {
              this.clearLocalStorage();
              callback(null);
            } else {
              callback(data.message);
            }
          })
      }
    });
  }
开发者ID:gabuladze,项目名称:vout,代码行数:26,代码来源:login.service.ts

示例5: signIn

    signIn(provider) {
        this.sub = this._auth.login(provider)
            .map(data => {

                console.log(data);
                this.ret = this.dbConnectService.post('usuarios', 'loginSocial', {
                    user: data['email'],
                    token_social: data['token'],
                    provider: data['provider']
                }).map((response: Response) => {
                    let ret = {
                        existe: (response['user'].nombre != null),
                        nombre: data['name'],
                        email: data['email'],
                        provider: data['provider']
                    };
                    return ret;

                }).catch((err: Response, caught: Observable<any>) => {
                    return Observable.throw(err);
                });


                return this.ret;
                // this.ret.subscribe(response=> {
                //     console.log(response);
                //     if (response == undefined) {
                //         Observable.throw({error: 'Usuario no encontrado, por favor registrese'});
                //         this.logout();
                //         return false;
                //     }
                //     this.persistLogin(response);
                // });
            }).share();

        return this.sub;
    }
开发者ID:arielcessario,项目名称:bayres-web,代码行数:37,代码来源:authentication.service.ts


注:本文中的angular2-social-login.AuthService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。