new session service

This commit is contained in:
Peter Maquiran
2023-07-10 12:32:01 +01:00
parent 9676bab7eb
commit f6f61a11ca
13 changed files with 116 additions and 71 deletions
+28 -42
View File
@@ -1,45 +1,31 @@
import { SHA1 } from 'crypto-js'
import { localstoreService } from './localstore.service'
class _DocumentManagementStore {
session: {
UserId: number,
Email: string,
UserName: string
FullName: string
RoleID: number
RoleDescription: string
OrganicEntityID: number
OrganicEntityName: string
Status: string
Authorization: string
AuthorizationJwt: string
}
constructor() {
const restore = localstoreService.get(this.keyName, {})
this.session = restore.session
}
get keyName() {
return SHA1("documentManagement").toString()
}
setData(data) {
this.session = data
localstoreService.set(this.keyName, {
session: this.session
})
}
clear() {
delete this.session
localstoreService.delete(this.keyName)
}
import { models } from 'src/plugin/src/'
import { DELETE, GET, SAVE } from '../models/beast-orm-function';
const { rewriteSave, rewriteGet, rewriteDelete } = models.core.localStorage.rewrite
export class CPSession extends models.LocalStorage {
static UserId: number = models.preset()
static Email: string = models.preset()
static UserName: string = models.preset()
static FullName: string = models.preset()
static RoleID: number = models.preset()
static RoleDescription: string = models.preset()
static OrganicEntityID: number = models.preset()
static OrganicEntityName: string = models.preset()
static Status: string = models.preset()
static Authorization: string = models.preset()
static AuthorizationJwt: string = models.preset()
}
export const DocumentManagementStore = new _DocumentManagementStore()
// content production
models.migrate({
databaseName:'content-production',
type: 'localStorage',
version: 1,
models: [CPSession],
})
rewriteGet.connect(GET, [CPSession])
rewriteSave.connect(SAVE, [CPSession])
rewriteDelete.connect(DELETE, [CPSession])
CPSession.get()