本文整理汇总了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;未经允许,请勿转载。 |
请发表评论