當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。