UNPKG

innotec-auth-plugin

Version:

The Innotec-Auth-Plugin is designed to handle all authentication processes for applications where's conntected to the innotec v2 infrastructure. Theses plugin provides different authentication processes:

35 lines (28 loc) 937 B
import { Injectable } from '@angular/core'; @Injectable() export class CookieService { constructor() {} public get(name: string) { let ca: Array<string> = document.cookie.split(';'); let caLen: number = ca.length; let cookieName = `${name}=`; let c: string; for (let i: number = 0; i < caLen; i += 1) { c = ca[i].replace(/^\s+/g, ''); if (c.indexOf(cookieName) === 0) { return c.substring(cookieName.length, c.length); } } return undefined; } public delete(name) { this.set(name, '', -1); } public set(name: string, value: string, expireDays: number, domain: string = '') { let d: Date = new Date(); d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000); let expires: string = `expires=${d.toUTCString()}`; let cpath: string = domain ? `; domain=${domain}` : ''; document.cookie = `${name}=${value}; ${expires}${cpath}`; } }