From 66636c6e9e822f84166259344e31a557a1b52eec Mon Sep 17 00:00:00 2001 From: Alix JEUDI--LEMOINE Date: Thu, 29 May 2025 15:19:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=94=20Added=20methods=20on=20LocalStor?= =?UTF-8?q?ageService=20for=20isAdmin=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/services/localstorage.service.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/services/localstorage.service.ts b/src/app/services/localstorage.service.ts index 20b725d..fd0f3a8 100644 --- a/src/app/services/localstorage.service.ts +++ b/src/app/services/localstorage.service.ts @@ -5,6 +5,7 @@ import { Injectable } from '@angular/core'; }) export class LocalStorageService { private readonly AUTH_TOKEN_KEY = 'auth_token'; + private readonly IS_ADMIN_KEY = 'isAdmin'; constructor() {} @@ -19,4 +20,16 @@ export class LocalStorageService { removeToken(): void { localStorage.removeItem(this.AUTH_TOKEN_KEY); } + + setIsAdmin(isAdmin: boolean): void { + localStorage.setItem(this.IS_ADMIN_KEY, isAdmin.toString()); + } + + getIsAdmin(): string | null { + return localStorage.getItem(this.IS_ADMIN_KEY); + } + + removeIsAdmin(): void { + localStorage.removeItem(this.IS_ADMIN_KEY); + } }