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


TypeScript Cookie.get方法代码示例

本文整理汇总了TypeScript中ng2-cookies/ng2-cookies.Cookie.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Cookie.get方法的具体用法?TypeScript Cookie.get怎么用?TypeScript Cookie.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ng2-cookies/ng2-cookies.Cookie的用法示例。


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

示例1: intercept

    intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

        // get the token from a service
        const authHeader = `Bearer ${Cookie.get('token')}`;
        const authReq = req.clone({setHeaders: {Authorization: authHeader}});

        if(authHeader)
            return next.handle(authReq);
        else
            return next.handle(req);    
    }
开发者ID:projectSHAI,项目名称:expressgular2,代码行数:11,代码来源:token-interceptor.service.ts

示例2: request

 request(method: METHOD, url: string, body?: any) {
   let token = Cookie.get('auth-token');
   var headers = new Headers();
   headers.append('Authorization', 'Bearer ' + token);
   switch (method) {
     case METHOD.GET:
       return this.get(url, headers);
     case METHOD.PUT:
       headers.append('Content-Type', 'application/x-www-form-urlencoded');
       return this.put(url, headers, body);
     case METHOD.DELETE:
       return this.delete(url, headers);
   }
 }
开发者ID:Omegapoint,项目名称:ng2-workshop,代码行数:14,代码来源:AuthHttp.ts

示例3: appInjector

export const isLoggedIn = (next: ComponentInstruction, previous: ComponentInstruction) => {
  let injector: Injector = appInjector(); // get the stored reference to the injector
  let auth: Auth = injector.get(Auth);
  let router: Router = injector.get(Router);
  let myCookie = JSON.parse(Cookie.get('loginRecord'));

  console.log(myCookie)

  // return a boolean or a promise that resolves a boolean
  return new Promise((resolve) => {
    if(myCookie != null){
      if (myCookie.loginIn) {
        resolve(true);
      } else {
        router.navigate(['/Login']);
        resolve(false);
      }
    }else{
        router.navigate(['/Login']);
        resolve(false);
    }

  });
};
开发者ID:terryshek,项目名称:angular2WebApp,代码行数:24,代码来源:is-logged-in.ts

示例4: ngOnInit

  ngOnInit() {

    this.user = this.store.select('userReducer');
    const token = Cookie.get('KycTokenSession');
    if (token && token !== '') {
      const data = this.apiService.validateToken(token);
      if (data.error) {
        this.apiService.signoutProccess();
        this.router.navigate(['/signin']);
      } else {
        this.session = data;
        let user = Object.assign(new User(), this.session.user);
        user.token = this.session.token;
        user.role = user.role.id;
        user.isLogged = true;
        this.store.dispatch({type: SET_VALIDATE_TOKEN, payload: true});
        this.store.dispatch({type: SET_USER, payload: user});
      }
    } else {
      this.store.dispatch({type: SET_VALIDATE_TOKEN, payload: true});
    }

    const route =  window.location.href.split('/');
  }
开发者ID:UHCToken,项目名称:kyc-gui,代码行数:24,代码来源:app.component.ts

示例5: createAuthorizationHeader

 createAuthorizationHeader(headers:Headers) {
   let basicAuthCredentials =  Cookie.get('basicAuthCredentials');
   if (basicAuthCredentials) {
     headers.append('Authorization', 'Basic ' + basicAuthCredentials);
   }
 }
开发者ID:heyMP,项目名称:elmsln,代码行数:6,代码来源:elmsln.service.ts

示例6: platformBrowserDynamic

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppSettings} from './app.settings';
import { AppModule } from './app.module';
import { Cookie } from 'ng2-cookies/ng2-cookies';

import { TranslateService } from 'ng2-translate/ng2-translate';

if(!Cookie.get('lang')){
	AppSettings._language = navigator.language;
	Cookie.set('lang', AppSettings._language);
}
else
{
	AppSettings._language = Cookie.get('lang');
}

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);

开发者ID:matmie,项目名称:Java-Projects,代码行数:19,代码来源:main.ts


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