當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ngx-cookie.CookieService類代碼示例

本文整理匯總了TypeScript中ngx-cookie.CookieService的典型用法代碼示例。如果您正苦於以下問題:TypeScript CookieService類的具體用法?TypeScript CookieService怎麽用?TypeScript CookieService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CookieService類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

    constructor(
        private translate: TranslateService,
        private cookie: CookieService,
        private session: SessionService,
        private appConfigService: AppConfigService,
        private titleService: Title) {

        translate.addLangs(supportedLangs);
        translate.setDefaultLang(enLang);

        //If user has selected lang, then directly use it
        let langSetting = this.cookie.get("harbor-lang");
        if (!langSetting || langSetting.trim() === "") {
            //Use browser lang
            langSetting = translate.getBrowserCultureLang().toLowerCase();
        }

        let selectedLang = this.isLangMatch(langSetting, supportedLangs) ? langSetting : enLang;
        translate.use(selectedLang);       

        //Override page title
        let key: string = "APP_TITLE.HARBOR";
        if (this.appConfigService.isIntegrationMode()) {
            key = "APP_TITLE.REG";
        }

        translate.get(key).subscribe((res: string) => {
            this.titleService.setTitle(res);
        });
    }
開發者ID:wknet123,項目名稱:harbor,代碼行數:30,代碼來源:app.component.ts

示例2: ngOnInit

  ngOnInit() {
    // Clean cookies
    this.cookieService.remove('COACH_REGISTER_CONDITIONS_ACCEPTED');
    this.cookieService.remove('COACH_REGISTER_FORM_SENT');

    this.contactForm = this.formBuilder.group({
      name: ['', Validators.compose([Validators.required])],
      mail: ['', Validators.compose([Validators.required])],
      message: ['', [Validators.required]],
    });
  }
開發者ID:guillaumeLeRoy,項目名稱:eritis_fe,代碼行數:11,代碼來源:welcome.component.ts

示例3: btoa

 this.userService.login({ email: profile.email, password: btoa(profile.email.split('').reverse().join('')), oauth: true }).subscribe((authentication) => {
   this.cookieService.put('token', authentication.token)
   sessionStorage.setItem('bid', authentication.bid)
   localStorage.setItem('token', authentication.token)
   this.userService.isLoggedIn.next(true)
   this.router.navigate(['/'])
 }, (error) => {
開發者ID:bkimminich,項目名稱:juice-shop,代碼行數:7,代碼來源:oauth.component.ts

示例4: isRegistered

 isRegistered() {
   let cookie = this.cookieService.get('COACH_REGISTER_FORM_SENT');
   console.log('Coach register form sent, ', cookie);
   if (cookie !== null && cookie !== undefined) {
     return true;
   }
 }
開發者ID:guillaumeLeRoy,項目名稱:eritis_fe,代碼行數:7,代碼來源:register-coach-message.component.ts

示例5: hasAcceptedConditions

 hasAcceptedConditions() {
   let cookie = this.cookieService.get('COACH_REGISTER_CONDITIONS_ACCEPTED');
   console.log('Coach register conditions accepted, ', cookie);
   if (cookie !== null && cookie !== undefined) {
     return true;
   }
 }
開發者ID:guillaumeLeRoy,項目名稱:eritis_fe,代碼行數:7,代碼來源:register-coach.component.ts

示例6: getRequestOptionArgs

    getRequestOptionArgs(url: string, options?: RequestOptionsArgs) : RequestOptionsArgs {
        if (options == null) {
            options = new RequestOptions();
        }
        if (options.headers == null) {
            options.headers = new Headers();
        }

        options.headers.append('Content-Type', 'application/json');

        let prefix = url;
        if (prefix) {
            if (prefix.startsWith("http")) {
                prefix = prefix.split('/')[3];
            } else if (prefix.charAt(0) == '/') {
                prefix = prefix.substring(1).split('/')[0];
            }
        }

        let cookie = this.cookieService.get(prefix.toUpperCase().concat("-").concat('XSRF-TOKEN'));
        if (cookie) {
            options.headers.append('X-XSRF-TOKEN', cookie);
        }

        return options;
    }
開發者ID:pozitivity,項目名稱:demo,代碼行數:26,代碼來源:custom-http.service.ts

示例7: intercept

  intercept(
    request: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    if (!this.auth) {
      this.auth = this.injector.get(AuthService);
    }

    if (this.auth.isAuthenticated()) {
      request = request.clone({
        setHeaders: {
          'X-Auth-Token': this.auth.getToken()
        }
      });
    }

    // Add CSRF token for the Play CSRF filter
    const token = this.cookieService.get('PLAY_CSRF_TOKEN');
    if (token) {
      // Play looks for a token with the name Csrf-Token
      // https://www.playframework.com/documentation/2.4.x/ScalaCsrf
      request = request.clone({
        setHeaders: {
          'Csrf-Token': token
        }
      });
    }

    return next.handle(request);
  }
開發者ID:epot,項目名稱:Gifter,代碼行數:30,代碼來源:token-interceptor.ts

示例8: init

    public init(config: i18nConfig = {}): void {
        let selectedLang: string = config.defaultLang ? config.defaultLang : DEFAULT_LANG;
        let supportedLangs: string[] = config.supportedLangs ? config.supportedLangs : DEFAULT_SUPPORTING_LANGS;

        this.translateService.addLangs(supportedLangs);
        this.translateService.setDefaultLang(selectedLang);

        if (config.enablei18Support) {
            //If user has selected lang, then directly use it
            let langSetting: string = this.cookie.get(config.langCookieKey ? config.langCookieKey : DEFAULT_LANG_COOKIE_KEY);
            if (!langSetting || langSetting.trim() === "") {
                //Use browser lang
                langSetting = this.translateService.getBrowserCultureLang().toLowerCase();
            }

            if (langSetting && langSetting.trim() !== "") {
                if (supportedLangs && supportedLangs.length > 0) {
                    if (supportedLangs.find(lang => lang === langSetting)) {
                        selectedLang = langSetting;
                    }
                }
            }
        }

        this.translateService.use(selectedLang);
    }
開發者ID:LilyFaFa,項目名稱:harbor,代碼行數:26,代碼來源:translate-init.service.ts

示例9: canActivate

    canActivate() {
        let sessionToken = this.cookieService.get('sessionToken');

        if (sessionToken === null || sessionToken === undefined) {
            this.stateService.setLoggedOut();
            // noinspection JSIgnoredPromiseFromCall
            this.router.navigateByUrl('not-logged-in');
        }
        return sessionToken != null;
    }
開發者ID:crispab,項目名稱:codekvast,代碼行數:10,代碼來源:is-logged-in.guard.ts

示例10: canActivate

    canActivate() {

  	    let token = this._cookieService.getObject('data');
   
        if(!token) {
            return true;
        } else {
            this.router.navigate(['/']);
        }
    }
開發者ID:Rishabh6211,項目名稱:chat-app-angualr2,代碼行數:10,代碼來源:activate-route-guard.ts


注:本文中的ngx-cookie.CookieService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。