Improve local storage

This commit is contained in:
Peter Maquiran
2021-07-18 20:20:30 +01:00
parent b6b95d929f
commit f5e65c1477
7 changed files with 61 additions and 34 deletions
+6 -5
View File
@@ -8,6 +8,7 @@ import { HttpService } from './http.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { AlertController } from '@ionic/angular';
import { LocalstoreService } from '../store/localstore.service';
@Injectable({
providedIn: 'root'
@@ -26,15 +27,15 @@ export class AuthService {
private storageService:StorageService,
private router:Router,
public alertController: AlertController,
private localstoreService: LocalstoreService
) {
this.headers = new HttpHeaders();
if (localStorage.getItem("user") != null) {
this.ValidatedUser = JSON.parse(localStorage.getItem('user'));
if (localstoreService.get('user', null) != null) {
this.ValidatedUser = localstoreService.get('user',{});
}
if (localStorage.getItem("userChat") != null) {
this.ValidatedUserChat = JSON.parse(localStorage.getItem('userChat'));
}
@@ -71,7 +72,7 @@ export class AuthService {
response.BasicAuthKey = user.BasicAuthKey
this.ValidatedUser = response;
localStorage.setItem('user', JSON.stringify(response));
this.localstoreService.set('user',response)
this.storageService.store(AuthConnstants.USER, response);