set data to store

This commit is contained in:
Peter Maquiran
2023-07-06 13:13:23 +01:00
parent c9c631536d
commit 8db8fa4ea3
4 changed files with 18 additions and 14 deletions
+3
View File
@@ -19,6 +19,7 @@ import { Platform } from '@ionic/angular';
import { FirstEnterService } from '../../services/first-enter.service'; import { FirstEnterService } from '../../services/first-enter.service';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { DocumentManagementStore } from 'src/app/store/documentManagement';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: './login.page.html', templateUrl: './login.page.html',
@@ -38,6 +39,7 @@ export class LoginPage implements OnInit {
sessionStore = SessionStore; sessionStore = SessionStore;
showPassword = false; showPassword = false;
passwordIcon = "eye"; passwordIcon = "eye";
DocumentManagementStore = DocumentManagementStore
constructor( constructor(
private notificatinsservice: NotificationsService, private notificatinsservice: NotificationsService,
@@ -152,6 +154,7 @@ export class LoginPage implements OnInit {
window.localStorage.clear(); window.localStorage.clear();
await MessageModel.deleteAll(); await MessageModel.deleteAll();
await DeleteMessageModel.deleteAll(); await DeleteMessageModel.deleteAll();
this.DocumentManagementStore.clear();
this.storage.clear(); this.storage.clear();
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
+5 -4
View File
@@ -19,6 +19,7 @@ import { InitialsService } from './functions/initials.service';
import { PermissionService } from './permission.service'; import { PermissionService } from './permission.service';
import { ChatSystemService } from 'src/app/services/chat/chat-system.service'; import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { DocumentManagementStore } from '../store/documentManagement';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@@ -32,6 +33,8 @@ export class AuthService {
tabIsActive = true tabIsActive = true
DocumentManagementStore = DocumentManagementStore
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private storageService:StorageService, private storageService:StorageService,
@@ -116,10 +119,8 @@ export class AuthService {
if(saveSession) { if(saveSession) {
/* this.SetSession(response, user) */ /* this.SetSession(response, user) */
this.storageService.store('userContentProduction',response) this.DocumentManagementStore.setData(response)
this.storageService.get('userContentProduction').then((value) =>{
console.log('JWW', value.AuthorizationJwt);
})
} }
} catch (error) { } catch (error) {
this.httpErroHandle.httpStatusHandle(error) this.httpErroHandle.httpStatusHandle(error)
+4 -4
View File
@@ -3,7 +3,7 @@ import { localstoreService } from './localstore.service'
export class documentManagementStore { export class documentManagementStore {
session: { static session: {
UserId: number, UserId: number,
Email: string, Email: string,
UserName: string UserName: string
@@ -17,18 +17,18 @@ export class documentManagementStore {
AuthorizationJwt: string AuthorizationJwt: string
} }
get keyName() { static get keyName() {
return SHA1("documentManagement").toString() return SHA1("documentManagement").toString()
} }
setData(data) { static setData(data) {
this.session = data this.session = data
localstoreService.set(this.keyName, { localstoreService.set(this.keyName, {
user: this.session user: this.session
}) })
} }
clear() { static clear() {
delete this.session delete this.session
localstoreService.delete(this.keyName) localstoreService.delete(this.keyName)
} }
File diff suppressed because one or more lines are too long