Browse Source

server token service refactoring

feature/ssr-migration-schematic
erdemcaygor 1 year ago
parent
commit
e6c4103368
  1. 16
      npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

16
npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

@ -6,12 +6,16 @@ import { OAuthStorage } from 'angular-oauth2-oidc';
})
export class ServerTokenStorageService implements OAuthStorage {
private cookies: Map<string, string> = new Map();
constructor(@Inject('cookies') c: any) {
const cookieItems = c.split(';');
for (const item of cookieItems) {
const [key, value] = item.split('=');
if (key && value) {
this.cookies.set(key.trim(), value.trim());
constructor(@Inject('cookies') c: string | undefined) {
if (c) {
const cookieItems = c.split(';');
for (const item of cookieItems) {
const index = item.indexOf('=');
if (index > -1) {
const key = item.slice(0, index).trim();
const value = item.slice(index + 1).trim();
this.cookies.set(key, value);
}
}
}
}

Loading…
Cancel
Save