mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
new session service
This commit is contained in:
+4
-2
@@ -77,7 +77,7 @@ _www/
|
|||||||
www2020
|
www2020
|
||||||
android copy/
|
android copy/
|
||||||
report.*
|
report.*
|
||||||
src/plugin/src/
|
src/plugin/
|
||||||
_node_modules/
|
_node_modules/
|
||||||
migrat/
|
migrat/
|
||||||
|
|
||||||
@@ -88,4 +88,6 @@ src/app/models/beast-orm-pro.ts
|
|||||||
|
|
||||||
|
|
||||||
src/app/pipes/process.service.spec.ts
|
src/app/pipes/process.service.spec.ts
|
||||||
src/app/pipes/process.service.ts
|
src/app/pipes/process.service.ts
|
||||||
|
|
||||||
|
/.angular
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { AES, SHA1, enc } from "crypto-js";
|
||||||
|
import { environment } from 'src/environments/environment'
|
||||||
|
|
||||||
|
|
||||||
|
function prefix() {
|
||||||
|
return environment.version.lastCommitNumber + environment.id+"-";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GET({key, localStorage, instance}) {
|
||||||
|
if(environment.storageProduction) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const newKey = prefix() + SHA1(key).toString()
|
||||||
|
const cipherText = localStorage.getItem(newKey)
|
||||||
|
const bytes = AES.decrypt(cipherText, newKey)
|
||||||
|
var decryptedData = bytes.toString(enc.Utf8);
|
||||||
|
const restoredData = JSON.parse(decryptedData)
|
||||||
|
|
||||||
|
Object.assign(instance, restoredData);
|
||||||
|
|
||||||
|
return restoredData
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
console.log(error)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return JSON.parse(localStorage.getItem(prefix() + key))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SAVE({key, localStorage, instance, dataToSave}) {
|
||||||
|
if(environment.storageProduction) {
|
||||||
|
const newKey = prefix() + SHA1(key).toString()
|
||||||
|
const stringifyData = JSON.stringify(dataToSave)
|
||||||
|
|
||||||
|
const cipherText = AES.encrypt(stringifyData, newKey).toString();
|
||||||
|
|
||||||
|
localStorage.setItem(newKey, cipherText)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
localStorage.setItem(prefix() + key, dataToSave)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DELETE({key, localStorage, instance}) {
|
||||||
|
if(environment.storageProduction) {
|
||||||
|
const newKey = prefix() + SHA1(key).toString()
|
||||||
|
localStorage.removeItem(newKey)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem(prefix() + key)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { models } from 'beast-orm'
|
//import { models } from 'beast-orm'
|
||||||
import { environment } from 'src/environments/environment'
|
import { environment } from 'src/environments/environment'
|
||||||
|
import { models } from 'src/plugin/src'
|
||||||
const { ArrayField, JsonField} = models.indexedDB.fields
|
const { ArrayField, JsonField} = models.indexedDB.fields
|
||||||
|
|
||||||
export class MessageModel extends models.Model {
|
export class MessageModel extends models.Model {
|
||||||
@@ -80,9 +81,6 @@ models.register({
|
|||||||
models: [PublicationModel, ActionModel]
|
models: [PublicationModel, ActionModel]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class WebtrixUserModel extends models.Model {
|
export class WebtrixUserModel extends models.Model {
|
||||||
FullName = models.CharField()
|
FullName = models.CharField()
|
||||||
Role = models.CharField()
|
Role = models.CharField()
|
||||||
@@ -102,4 +100,3 @@ models.register({
|
|||||||
version: 14,
|
version: 14,
|
||||||
models: [PublicationModel, ActionModel]
|
models: [PublicationModel, ActionModel]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface Environment {
|
|||||||
PR: string
|
PR: string
|
||||||
VP: string
|
VP: string
|
||||||
dispatchPR: string
|
dispatchPR: string
|
||||||
|
storageProduction: boolean
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +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';
|
import { CPSession } from 'src/app/store/documentManagement';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
templateUrl: './login.page.html',
|
templateUrl: './login.page.html',
|
||||||
@@ -39,7 +39,6 @@ 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,
|
||||||
@@ -119,7 +118,7 @@ export class LoginPage implements OnInit {
|
|||||||
const loader = this.toastService.loading()
|
const loader = this.toastService.loading()
|
||||||
|
|
||||||
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
||||||
await this.authService.loginContenteProduction(this.userattempt, {saveSession: false})
|
await this.authService.loginContenteProduction(this.userattempt, {saveSession: true})
|
||||||
|
|
||||||
|
|
||||||
loader.remove()
|
loader.remove()
|
||||||
@@ -154,7 +153,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();
|
CPSession.clear();
|
||||||
this.storage.clear();
|
this.storage.clear();
|
||||||
|
|
||||||
await this.authService.SetSession(attempt, this.userattempt);
|
await this.authService.SetSession(attempt, this.userattempt);
|
||||||
|
|||||||
@@ -19,7 +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';
|
import { CPSession } from '../store/documentManagement';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -32,8 +32,6 @@ export class AuthService {
|
|||||||
opts:any;
|
opts:any;
|
||||||
|
|
||||||
tabIsActive = true
|
tabIsActive = true
|
||||||
|
|
||||||
DocumentManagementStore = DocumentManagementStore
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
@@ -78,9 +76,6 @@ export class AuthService {
|
|||||||
async login(user: UserForm, {saveSession = true}): Promise<LoginUserRespose> {
|
async login(user: UserForm, {saveSession = true}): Promise<LoginUserRespose> {
|
||||||
user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password,user.username ));
|
user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password,user.username ));
|
||||||
|
|
||||||
// Basic peter.maquiran@equilibrium.co.ao:senha123456
|
|
||||||
// console.log(user.BasicAuthKey)
|
|
||||||
|
|
||||||
this.headers = this.headers.set('Authorization', user.BasicAuthKey);
|
this.headers = this.headers.set('Authorization', user.BasicAuthKey);
|
||||||
this.opts = {
|
this.opts = {
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
@@ -119,7 +114,8 @@ export class AuthService {
|
|||||||
|
|
||||||
if(saveSession) {
|
if(saveSession) {
|
||||||
/* this.SetSession(response, user) */
|
/* this.SetSession(response, user) */
|
||||||
this.DocumentManagementStore.setData(response)
|
console.log('teste', response);
|
||||||
|
CPSession.save(response)
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -882,13 +882,13 @@ export class RoomService {
|
|||||||
|
|
||||||
private async findMessageInDBByData({localReference, _id}) {
|
private async findMessageInDBByData({localReference, _id}) {
|
||||||
|
|
||||||
const a = await MessageModel.filter({localReference: localReference})
|
const a = await MessageModel.filter({localReference: localReference}).execute()
|
||||||
if(a.length >= 1) {
|
if(a.length >= 1) {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const c = await MessageModel.filter({_id: _id})
|
const c = await MessageModel.filter({_id: _id}).execute()
|
||||||
if(c.length >= 1) {
|
if(c.length >= 1) {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { fullTaskList } from '../models/dailyworktask.model';
|
|||||||
import { ChangeProfileService } from './change-profile.service';
|
import { ChangeProfileService } from './change-profile.service';
|
||||||
import { SessionStore } from '../store/session.service';
|
import { SessionStore } from '../store/session.service';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
|
import { CPSession } from '../store/documentManagement';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -42,14 +43,15 @@ export class ProcessesService {
|
|||||||
|
|
||||||
|
|
||||||
setHeader() {
|
setHeader() {
|
||||||
|
|
||||||
|
console.log('CPSession.AuthorizationJwt', CPSession.AuthorizationJwt);
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
|
||||||
|
|
||||||
this.headers2 = new HttpHeaders();
|
this.headers2 = new HttpHeaders();
|
||||||
this.headers2 = this.headers2.set('Authorization',"bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiIyNjIiLCJ1bmlxdWVfbmFtZSI6IkdpbHNvbiBNYW51ZWwiLCJlbWFpbCI6ImdpbHNvbi5tYW51ZWxAZ2FiaW5ldGVkaWdpdGFsLmxvY2FsIiwicm9sZSI6IlNlY3JldMOhcmlvIEdlcmFsIiwiZ3JvdXBzaWQiOiJHYWJpbmV0ZSBkZSBUZWNub2xvZ2lhcyBkZSBJbmZvcm1hw6fDo28iLCJvcmdhbmljZW50aXR5aWREIjoiMTA2IiwibmJmIjoxNjg4NTg0NTYzLCJleHAiOjE3MjAxMjA1NjMsImlhdCI6MTY4ODU4NDU2MywiaXNzIjoiOGIxMzBhN2YwLWM3YjctNDdzMjMtOWE4ZC1kNTlhMDE5YWY3NDkiLCJhdWQiOiJkMjh3dzE0NTMtM2M2OC00MWFkLThiNmMtYTUzNDUzODNlMGMyIn0.QDCrQsCH59GQMoudZTHyCMwwHYVwz1mZkLTzvzAwh64"
|
this.headers2 = this.headers2.set('Authorization',"bearer "+ CPSession.AuthorizationJwt);
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadFile(formData:any){
|
uploadFile(formData:any){
|
||||||
|
|||||||
@@ -1,45 +1,31 @@
|
|||||||
import { SHA1 } from 'crypto-js'
|
import { models } from 'src/plugin/src/'
|
||||||
import { localstoreService } from './localstore.service'
|
import { DELETE, GET, SAVE } from '../models/beast-orm-function';
|
||||||
|
const { rewriteSave, rewriteGet, rewriteDelete } = models.core.localStorage.rewrite
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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()
|
||||||
@@ -23,6 +23,7 @@ export const DevProd: Environment = {
|
|||||||
PR: 'Titular',
|
PR: 'Titular',
|
||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Titular',
|
dispatchPR: 'Despachos Titular',
|
||||||
|
storageProduction: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -48,4 +49,5 @@ export const DevDev: Environment = {
|
|||||||
PR: 'Titular',
|
PR: 'Titular',
|
||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Titular',
|
dispatchPR: 'Despachos Titular',
|
||||||
|
storageProduction: false,
|
||||||
};
|
};
|
||||||
@@ -23,6 +23,7 @@ export const doneITProd: Environment = {
|
|||||||
PR: 'Titular',
|
PR: 'Titular',
|
||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Titular',
|
dispatchPR: 'Despachos Titular',
|
||||||
|
storageProduction: true
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doneITDev: Environment = {
|
export const doneITDev: Environment = {
|
||||||
@@ -47,4 +48,5 @@ export const doneITDev: Environment = {
|
|||||||
PR: 'Titular',
|
PR: 'Titular',
|
||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Titular',
|
dispatchPR: 'Despachos Titular',
|
||||||
|
storageProduction: false
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,8 @@ export const oaprProd: Environment = {
|
|||||||
PR: 'PR',
|
PR: 'PR',
|
||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Presidênciais',
|
dispatchPR: 'Despachos Presidênciais',
|
||||||
sentryUrl: 'https://9920cc36f1d740b987426ee8d80cf588@o4504340905525248.ingest.sentry.io/4504340946419712'
|
sentryUrl: 'https://9920cc36f1d740b987426ee8d80cf588@o4504340905525248.ingest.sentry.io/4504340946419712',
|
||||||
|
storageProduction: true
|
||||||
};
|
};
|
||||||
|
|
||||||
export const oaprDev: Environment = {
|
export const oaprDev: Environment = {
|
||||||
@@ -48,4 +49,5 @@ export const oaprDev: Environment = {
|
|||||||
VP: '',
|
VP: '',
|
||||||
dispatchPR: 'Despachos Presidênciais',
|
dispatchPR: 'Despachos Presidênciais',
|
||||||
sentryUrl: 'https://9920cc36f1d740b987426ee8d80cf588@o4504340905525248.ingest.sentry.io/4504340946419712',
|
sentryUrl: 'https://9920cc36f1d740b987426ee8d80cf588@o4504340905525248.ingest.sentry.io/4504340946419712',
|
||||||
|
storageProduction: false
|
||||||
};
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "10eaf2964",
|
"shortSHA": "9676bab7e",
|
||||||
"SHA": "10eaf29645ac3edb6e68e136c35178b087aa321e",
|
"SHA": "9676bab7eb0427cf26a4970ce8bd7d96deaf504b",
|
||||||
"branch": "feature/gabinete-search",
|
"branch": "feature/gabinete-search",
|
||||||
"lastCommitAuthor": "'Peter Maquiran'",
|
"lastCommitAuthor": "'Peter Maquiran'",
|
||||||
"lastCommitTime": "'Thu Jul 6 13:17:36 2023 +0100'",
|
"lastCommitTime": "'Thu Jul 6 13:35:11 2023 +0100'",
|
||||||
"lastCommitMessage": "change class",
|
"lastCommitMessage": "main data of refresh",
|
||||||
"lastCommitNumber": "5039",
|
"lastCommitNumber": "5040",
|
||||||
"change": "",
|
"change": "",
|
||||||
"changeStatus": "On branch feature/gabinete-search\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/store/documentManagement.ts",
|
"changeStatus": "On branch feature/gabinete-search\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: .gitignore\n\tnew file: src/app/models/beast-orm-function.ts\n\tmodified: src/app/models/beast-orm.ts\n\tmodified: src/app/models/envarioment.ts\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/chat/room.service.ts\n\tmodified: src/app/services/processes.service.ts\n\tmodified: src/app/store/documentManagement.ts\n\tmodified: src/environments/suport/dev.ts\n\tmodified: src/environments/suport/doneIt.ts\n\tmodified: src/environments/suport/oapr.ts",
|
||||||
"changeAuthor": "peter.maquiran"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user