change login v1 to v2

This commit is contained in:
Peter Maquiran
2024-11-06 10:38:58 +01:00
parent 5c0bd094ca
commit 5c18f281bc
40 changed files with 271 additions and 246 deletions
+101 -20
View File
@@ -1,27 +1,108 @@
import { z } from "zod";
import { SHA1 } from 'crypto-js'
import { localstoreService } from "src/app/store/localstore.service";
// import { z } from "zod";
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
// // Define the schema for the user object
// const UserSchema = z.object({
// wxUserId: z.number(),
// wxFullName: z.string(),
// wxeMail: z.string(),
// role: z.string(),
// roleId: z.number(),
// userPhoto: z.string(),
// adUserSID: z.string(),
// });
// // Define the schema for the main response object
// const UserDataSchema = z.object({
// user: UserSchema,
// authorization: z.string(),
// refreshToken: z.string(),
// permissions: z.array(z.number()),
// });
// export type IUser = z.infer<typeof UserDataSchema>
// export class UserEntity {
// wxUserId: number
// wxFullName: string
// wxeMail: string
// role: string
// roleId: number
// userPhoto: string
// adUserSID: string
// authorization: string
// refreshToken: string
// permissions: number[]
// Profile: 'PR' | 'MDGPR'| 'Consultant'| 'SGGPR'| 'Unknown'
// constructor(input: IUser) {
// Object.assign(this, input)
// if (input) {
// if (input?.user?.roleId == 100000014) {
// this.Profile = 'PR'
// } else if (input.user.roleId == 100000011) {
// this.Profile = 'MDGPR'
// } else if (input.user.roleId == 99999872) {
// this.Profile = 'Consultant'
// } else if (input.user.roleId == 99999886) {
// this.Profile = 'SGGPR'
// } else {
// this.Profile = 'Unknown'
// }
// }
// }
// }
import { z } from 'zod';
const LoginUserResponseSchema = z.object({
UserId: z.number(),
Authorization: z.string(),
Email: z.string().email(),
FullName: z.string(),
RoleDescription: z.string(),
RoleID: z.number(),
Profile: z.string(), // You can further define the Profile if you have more details
UserPermissions: z.array(z.number()), // Same as above, you can define more details if needed
});
// Define the schema for the main response object
const UserDataSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
type LoginUserResponse = z.infer<typeof LoginUserResponseSchema>;
const CalendarInterfaceSchema = z.object({
CalendarId: z.string(),
CalendarName: z.enum(["Oficial", "Pessoal"]),
CalendarRoleId: z.string(),
Id: z.number(),
OwnerUserId: z.unknown(), // You can define more specifically based on your requirements
});
export type IUser = z.infer<typeof UserDataSchema>
type CalendarInterface = z.infer<typeof CalendarInterfaceSchema>;
const UserSessionSchema = z.object({
UserId: z.number(),
Authorization: z.string(),
Email: z.string().email(),
FullName: z.string(),
RoleDescription: z.string(),
RoleID: z.number(),
Password: z.string(),
RochetChatUserId: z.string(),
Profile: z.enum(['PR', 'MDGPR', 'Consultant', 'SGGPR', 'Unknown']),
LoginPreference: z.enum(['None', 'Password', 'Pin', null]).nullable(),
PIN: z.string(),
Inactivity: z.boolean(),
UrlBeforeInactivity: z.string(),
UserPermissions: z.unknown(), // Again, you can define it more explicitly if needed
UserPhoto: z.string(),
RefreshToken: z.string(),
});
type UserSession = z.infer<typeof UserSessionSchema>;
export class UserEntity {
@@ -37,7 +118,7 @@ export class UserEntity {
permissions: number[]
Profile: 'PR' | 'MDGPR'| 'Consultant'| 'SGGPR'| 'Unknown'
constructor(input: IUser) {
constructor(input: any) {
Object.assign(this, input)
if (input) {
+18
View File
@@ -0,0 +1,18 @@
import { UserLoginOutputResponse } from "../repository/user-remote-repository";
import { UserLoginOutput } from "../use-case/user-login-use-case.service";
export class UserLoginMapper{
static toDomainData(input: UserLoginOutputResponse): UserLoginOutput {
return {
RefreshToken: input.data.refreshToken,
Authorization: input.data.authorization,
Email: input.data.user.wxeMail,
FullName: input.data.user.wxeMail,
RoleDescription: input.data.user.role,
RoleID: input.data.user.roleId,
UserId: input.data.user.wxUserId,
UserPermissions: input.data.permissions,
Profile: ''
}
}
}
@@ -1,7 +1,7 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Result } from "neverthrow";
import { HttpResult } from "src/app/infra/http/type";
import { UserLoginInput, UserLoginOutput } from "../use-case/user-login-use-case.service";
import { UserLoginInput } from "../use-case/user-login-use-case.service";
import { z } from "zod";
const UserRepositoryLoginParams = z.object({
@@ -9,8 +9,37 @@ const UserRepositoryLoginParams = z.object({
ChannelId: z.number()
})
export type IUserRepositoryLoginParams = z.infer<typeof UserRepositoryLoginParams>
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserLoginOutputSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
// Define the main schema for the response
const LoginUserResponseSchema = z.object({
success: z.boolean(),
message: z.nullable(z.string()), // Message can be null
data: UserLoginOutputSchema,
});
export type UserLoginOutputResponse = z.infer<typeof LoginUserResponseSchema>
export type IUserRepositoryLoginParams = z.infer<typeof UserRepositoryLoginParams>
export abstract class IUserRemoteRepository {
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutput>, HttpErrorResponse>>
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutputResponse>, HttpErrorResponse>>
}
@@ -3,9 +3,11 @@ import { z } from 'zod';
import { IUserRemoteRepository } from '../repository/user-remote-repository';
import { XTracerAsync, TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
import { zodSafeValidation } from 'src/app/utils/zodValidation';
import { AlertController, Platform } from '@ionic/angular';
import { Platform } from '@ionic/angular';
import { AESEncrypt } from 'src/app/services/aesencrypt.service';
import { UserLoginMapper } from '../mapper/user-login';
import { UserSession } from 'src/app/models/user.model';
import { SessionStore } from 'src/app/store/session.service';
const UserLoginInputSchema = z.object({
username: z.string(),
@@ -16,34 +18,22 @@ export type UserLoginInput = z.infer<typeof UserLoginInputSchema>
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserLoginOutputSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
// Define the main schema for the response
const LoginUserResponseSchema = z.object({
success: z.boolean(),
message: z.nullable(z.string()), // Message can be null
data: UserLoginOutputSchema,
UserId: z.number(),
Authorization: z.string(),
RefreshToken: z.string(),
Email: z.string().email(),
FullName: z.string(),
RoleDescription: z.string(),
RoleID: z.number(),
Profile: z.string(), // You can further define the Profile if you have more details
UserPermissions: z.array(z.number()), // Same as above, you can define more details if needed
});
export type UserLoginOutput = z.infer<typeof LoginUserResponseSchema>
export type UserLoginOutput = z.infer<typeof UserLoginOutputSchema>
@Injectable({
providedIn: 'root'
@@ -76,13 +66,28 @@ export class UserLoginUseCaseService {
ChannelId: channelId
})
if(result.isOk()) {
if(result.value) {
return result.map(e => {
const data = UserLoginMapper.toDomainData(e.data)
const session: UserSession = Object.assign(SessionStore.user, data)
if (session.RoleID == 100000014) {
session.Profile = 'PR'
} else if (session.RoleID == 100000011) {
session.Profile = 'MDGPR'
} else if (session.RoleID == 99999872) {
session.Profile = 'Consultant'
} else if (session.RoleID == 99999886) {
session.Profile = 'SGGPR'
} else {
session.Profile = 'Unknown'
}
}
return result.map(e => e.data.data)
SessionStore.reset(session)
return UserLoginMapper.toDomainData(e.data)
})
} else {
tracing.setAttribute('parameter error','true')
@@ -9,7 +9,7 @@ import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discar
import { ExpedienteDetailPage } from 'src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
import { SearchList } from 'src/app/models/search-document';
import { SearchPage } from 'src/app/pages/search/search.page';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@@ -85,7 +85,7 @@ export class CreateProcessPage implements OnInit {
documents: SearchList[] = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
toppings = new FormControl();
@@ -5,7 +5,7 @@ import { Event } from 'src/app/models/event.model'
import { EventPerson } from 'src/app/models/eventperson.model';
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchDocumentDetails, SearchFolderDetails, SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service';
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
import { ToastService } from 'src/app/services/toast.service';
@@ -92,7 +92,7 @@ export class DocumentSetUpMeetingPage implements OnInit {
formLocationSatus: boolean = false;
showAttendees = false;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
emptyTextDescription = "Selecionar intervenientes";
document: SearchFolderDetails | SearchDocumentDetails | any;
-12
View File
@@ -6,18 +6,6 @@ export class UserForm {
}
export class LoginUserRespose {
UserId: number;
Authorization: string;
Email: string
FullName: string
RoleDescription: string
RoleID: number
Profile: any;
UserPermissions: any;
}
export class calendarInterface {
CalendarId: string
CalendarName: "Oficial" | "Pessoal";
@@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { EventPerson } from 'src/app/models/eventperson.model';
import { ModalController, NavParams } from '@ionic/angular';
import { ThemeService } from 'src/app/services/theme.service'
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { SessionStore } from 'src/app/store/session.service';
import { Router } from '@angular/router';
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
@@ -25,7 +25,7 @@ export class AttendeesPageModal implements OnInit {
taskParticipants:EventPerson[] = [];
taskParticipantsCc:EventPerson[] = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
hideExternalDomain = true;
taskType: any;
@@ -7,7 +7,7 @@ import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart
import { AttachmentsService } from 'src/app/services/attachments.service';
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@@ -111,7 +111,7 @@ export class BookMeetingModalPage implements OnInit {
sessionStore = SessionStore;
SessionStore=SessionStore
environment = environment
loggeduser: LoginUserRespose;
loggeduser: UserSession;
eventPersons: EventPerson[];
contacts: EventPerson[];
@@ -12,7 +12,7 @@ import { ExpedienteDetailPage } from '../expediente-detail/expediente-detail.pag
import { AlertService } from 'src/app/services/alert.service';
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@@ -98,7 +98,7 @@ export class ExpedientTaskModalPage implements OnInit {
taskResult: any = {}
loggeduser: LoginUserRespose;
loggeduser: UserSession;
toppings = new FormControl();
Form: FormGroup;
@@ -26,7 +26,7 @@ import { NewGroupPage } from 'src/app/ui/chat/modal/new-group/new-group.page';
import { DataService } from 'src/app/services/data.service';
import { RouteService } from 'src/app/services/route.service';
import { Storage } from '@ionic/storage';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { TaskService } from 'src/app/services/task.service';
@@ -61,7 +61,7 @@ export class ExpedienteDetailPage implements OnInit {
onlinecheck: boolean;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
showOptions = false
constructor(
@@ -7,7 +7,7 @@ import { ViewEventPage } from 'src/app/ui/agenda/modal/view-event/view-event.pag
import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
import { ExpedientTaskModalPage } from '../../expediente/expedient-task-modal/expedient-task-modal.page';
import { BookMeetingModalPage } from '../../expediente/book-meeting-modal/book-meeting-modal.page';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { OptsExpedientePrPage } from 'src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page';
import { ToastService } from 'src/app/services/toast.service';
@@ -41,7 +41,7 @@ export class ExpedientePrPage implements OnInit {
intervenientes: any = [];
cc: any = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
documents: SearchList[] = [];
attachments:any;
isDelegated: boolean;
@@ -4,7 +4,7 @@ import { CalendarComponent } from 'ionic2-calendar';
import { ProcessesService } from 'src/app/services/processes.service';
import { ModalController } from '@ionic/angular';
import { ExpedienteDetailPage } from 'src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ThemeService } from 'src/app/services/theme.service'
@@ -26,7 +26,7 @@ export class ExpedientesPrPage implements OnInit {
serialNumber:string;
showLoader:boolean;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
@Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>();
skeletonLoader = true
@@ -1,7 +1,7 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import {NavigationEnd, NavigationExtras, Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ExpedientsPage } from 'src/app/shared/gabinete-digital/expedients/expedients.page';
import { PendentesPage } from 'src/app/shared/gabinete-digital/pendentes/pendentes.page';
import { EventsToApprovePage } from 'src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page';
@@ -57,7 +57,7 @@ export class GabineteDigitalPage implements OnInit {
serialNumber: string;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
mdgpr = "MDGPR";
pr = "PR";
@@ -10,7 +10,7 @@ import { CreateProcessPage } from 'src/app/modals/create-process/create-process.
import { DelegarPage } from 'src/app/modals/delegar/delegar.page';
import { DarParecerPage } from 'src/app/modals/dar-parecer/dar-parecer.page';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { ForwardPage } from 'src/app/modals/forward/forward.page';
@@ -47,7 +47,7 @@ export class PedidoPage implements OnInit {
caller: string;
intervenientes: any = []
cc: any = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
taskArrayActions = [];
showOptions = false
@@ -6,7 +6,7 @@ import { customTask } from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { AlertService } from 'src/app/services/alert.service';
import { PendentesStore } from 'src/app/store/pendestes-store.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
@@ -31,7 +31,7 @@ export class PendentesPage implements OnInit {
serialNumber: string;
totalDocs: any;
showLoader: boolean;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
@Input() profile: string;
segment: string;
+2 -2
View File
@@ -86,7 +86,7 @@ export class InactivityPage implements OnInit {
// if current attemp is equal to the current user
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt, this.userattempt);
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
// this.authService.loginChat();
@@ -101,7 +101,7 @@ export class InactivityPage implements OnInit {
window.localStorage.clear();
SessionStore.setInativity(true)
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt, this.userattempt);
}
this.enterWithPassword = false
+5 -9
View File
@@ -133,30 +133,26 @@ export class LoginPage implements OnInit {
const loader = this.toastService.loading()
this.UserService.login({
let attempt = await this.UserService.login({
username: newUserName.trim(),
password: this.password.trim(),
})
let attempt = await this.authService.login(this.userattempt, { saveSession: false })
/* const data = await this.authService.loginContenteProduction(this.userattempt, { saveSession: true }) */
loader.remove()
if (attempt) {
if (attempt.isOk()) {
if (attempt.UserId == SessionStore.user.UserId) {
if (attempt.value.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt.value, this.userattempt);
this.changeProfileService.run();
try {
await this.AgendaDataRepositoryService.getSharedCalendar()
this.NotificationHolderService.clear()
await this.authService.loginToChatWs();
this.NotificationRepositoryService.init()
@@ -189,7 +185,7 @@ export class LoginPage implements OnInit {
window.localStorage.clear();
this.storage.clear();
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt.value, this.userattempt);
this.NotificationRepositoryService.init()
/* CPSession.save(data) */
+2 -2
View File
@@ -3,7 +3,7 @@ import { Attachment } from '../models/attachment.model';
import { Observable } from 'rxjs';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { LoginUserRespose } from '../models/user.model';
import { UserSession } from '../models/user.model';
import { SessionStore } from '../store/session.service';
import { File } from '@ionic-native/file/ngx';
import { Platform } from '@ionic/angular';
@@ -14,7 +14,7 @@ import { ChangeProfileService } from './change-profile.service';
})
export class AttachmentsService {
loggeduser: LoginUserRespose;
loggeduser: UserSession;
headers: HttpHeaders;
constructor(
+8 -103
View File
@@ -1,7 +1,7 @@
import { Injectable, ErrorHandler } from '@angular/core';
import { StorageService } from './storage.service';
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { LoginUserRespose, UserForm, UserSession } from '../models/user.model';
import { UserForm, UserSession } from '../models/user.model';
import { environment } from 'src/environments/environment';
import { BehaviorSubject, of } from 'rxjs';
import { AlertController, Platform } from '@ionic/angular';
@@ -15,6 +15,7 @@ import { PermissionService } from './permission.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { captureException } from '@sentry/angular';
import { catchError, tap } from 'rxjs/operators';
import { UserLoginOutput } from '../core/user/use-case/user-login-use-case.service';
@Injectable({
providedIn: 'root'
})
@@ -42,12 +43,6 @@ export class AuthService {
private errorHandler: ErrorHandler,
private platform: Platform,) {
if (SessionStore.exist) {
if (this.p.userPermission(this.p.permissionList.Chat.access) == true) {
this.loginToChatWs()
}
}
window.addEventListener('focus', (event) => {
if (!this.tabIsActive) {
@@ -70,7 +65,7 @@ export class AuthService {
}
async login(user: UserForm, { saveSession = true }): Promise<LoginUserRespose> {
async login(user: UserForm, { saveSession = true }): Promise<UserSession> {
user.BasicAuthKey = btoa(user.username + ':' + this.aesencrypt.encrypt(user.password, user.username));
this.headers = this.headers.set('Authorization', user.BasicAuthKey);
@@ -95,11 +90,11 @@ export class AuthService {
let response: any;
try {
response = await this.http.post<LoginUserRespose>(environment.apiURL + "UserAuthentication/Login", body, this.opts).toPromise();
response = await this.http.post<UserSession>(environment.apiURL + "UserAuthentication/Login", body, this.opts).toPromise();
if (saveSession) {
this.SetSession(response, user)
// this.SetSession(response, user)
}
} catch (error) {
this.errorHandler.handleError(error);
@@ -116,7 +111,7 @@ export class AuthService {
}
async loginContenteProduction(user: UserForm, { saveSession = true }): Promise<LoginUserRespose> {
async loginContenteProduction(user: UserForm, { saveSession = true }): Promise<UserSession> {
user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password, user.username));
this.headers = this.headers.set('Authorization', user.BasicAuthKey);
@@ -127,7 +122,7 @@ export class AuthService {
let response: any;
try {
response = await this.http.post<LoginUserRespose>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
response = await this.http.post<UserSession>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
console.log('JWT', response)
if (saveSession) {
@@ -147,96 +142,6 @@ export class AuthService {
// async UpdateLogin() {}
SetSession(response: LoginUserRespose, user: UserForm) {
const session: UserSession = Object.assign(SessionStore.user, response)
if (response) {
if (session.RoleID == 100000014) {
session.Profile = 'PR'
} else if (session.RoleID == 100000011) {
session.Profile = 'MDGPR'
} else if (session.RoleID == 99999872) {
session.Profile = 'Consultant'
} else if (session.RoleID == 99999886) {
session.Profile = 'SGGPR'
} else {
session.Profile = 'Unknown'
}
session.Password = user.password
SessionStore.reset(session)
return true;
}
this.initialsService.getInitials(session.FullName);
}
loginToChatWs() {
setTimeout(() => {
//if (SessionStore.user.ChatData?.data) {
// this.RochetChatConnectorService.logout();
// this.RochetChatConnectorService.connect();
// this.RochetChatConnectorService.login().then((message: any) => {
// console.log('Chat login', message)
// SessionStore.user.RochetChatUserId = message.result.id
// SessionStore.save()
// this.ChatSystemService.loadChat()
// this.RochetChatConnectorService.setStatus('online')
// window['RochetChatConnectorService'] = this.RochetChatConnectorService
// setTimeout(() => {
// this.ChatSystemService.getAllRooms();
// this.RochetChatConnectorService.setStatus('online')
// }, 200);
// }).catch((error) => {
// console.error(SessionStore.user.ChatData, 'web socket login', error)
// if(window.location.pathname.includes('/home/')) {
// setTimeout(() => {
// this.loginToChatWs();
// }, 4000)
// }
// })
//}
// before sending a message with a attachment
8
// this.NfService.downloadFileMsg = async (message: MessageService, room?: RoomService) => {
// //
// let downloadFile = "";
// if (message.file.type == "application/img") {
// const event: any = await this.AttachmentsService.downloadFile(message.file.guid).toPromise();
// if (event.type === HttpEventType.DownloadProgress) {
// //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
// return true
// } else if (event.type === HttpEventType.Response) {
// downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
// message.file = {
// guid: message.file.guid,
// image_url: downloadFile,
// type: message.file.type
// }
// return true
// }
// return false
// }
// };
}, 1)
}
autologout(expirationDate: number) {
setTimeout(() => {
this.logout();
@@ -277,7 +182,7 @@ export class AuthService {
let response: any;
try {
response = await this.http.delete<LoginUserRespose>(environment.apiURL + "userauthentication/Logout", this.opts).toPromise();
response = await this.http.delete<UserSession>(environment.apiURL + "userauthentication/Logout", this.opts).toPromise();
SessionStore.user.Authorization = "";
SessionStore.user.RefreshToken = "";
} catch (error) {
+5 -2
View File
@@ -168,9 +168,12 @@ export class NotificationsService {
DeletePostToken() {
const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${this.token}`;
if(this.token) {
const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${this.token}`;
this.DeleteToken(geturl)
}
this.DeleteToken(geturl)
}
postToken(token, geturl, tracing: TracingType) {
+2 -2
View File
@@ -4,7 +4,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
import { UserSession } from '../models/user.model';
import { OrganicEntity } from 'src/app/models/organic-entity.model';
import { SessionStore } from '../store/session.service';
import { ChangeProfileService } from './change-profile.service';
@@ -15,7 +15,7 @@ import { ChangeProfileService } from './change-profile.service';
export class OrganicEntityService {
authheader = {};
loggeduser: LoginUserRespose;
loggeduser: UserSession;
headers: HttpHeaders;
constructor(
+2 -2
View File
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { LoginUserRespose } from '../models/user.model';
import { UserSession } from '../models/user.model';
import { environment } from 'src/environments/environment';
import { Observable } from 'rxjs';
import { DocumentSetUpMeeting } from '../models/CallMeeting';
@@ -16,7 +16,7 @@ import { SessionStore } from '../store/session.service';
export class ProcessesService {
authheader = {};
loggeduser: LoginUserRespose;
loggeduser: UserSession;
headers: HttpHeaders;
headers2: HttpHeaders;
+2 -2
View File
@@ -2,7 +2,7 @@ import { Injectable, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
import { UserSession } from '../models/user.model';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators'
import { Publication } from '../models/publication';
@@ -19,7 +19,7 @@ export class PublicationsService {
authheader = {};
loggeduser: LoginUserRespose;
loggeduser: UserSession;
headers: HttpHeaders;
constructor(private http: HttpClient, user: AuthService,
+2 -2
View File
@@ -4,7 +4,7 @@ import { Event } from '../models/event.model';
import { from, Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
import { UserSession } from '../models/user.model';
import { EventSearch } from "src/app/models/event-search";
import { TopSearch } from 'src/app/models/top-search';
import { SessionStore } from '../store/session.service';
@@ -16,7 +16,7 @@ import { ChangeProfileService } from './change-profile.service';
export class SearchService {
// state
authheader = {};
loggeduser: LoginUserRespose;
loggeduser: UserSession;
headers: HttpHeaders;
categories= Array;
@@ -4,7 +4,7 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { ThemeService } from 'src/app/services/theme.service'
import { ViewChild } from '@angular/core';
import { Searchbar } from 'ionic-angular';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { SessionStore } from 'src/app/store/session.service';
import { Router } from '@angular/router';
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
@@ -46,7 +46,7 @@ export class AttendeePage implements OnInit {
LtaskParticipants: EventPerson[] = [];
LtaskParticipantsCc: EventPerson[] = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
listOfNotAllowdRoute = ['/home/gabinete-digital/despachos/', ]
selectedUserCalendar:any;
@@ -1,6 +1,6 @@
import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ThemeService } from 'src/app/services/theme.service';
import { TaskService } from 'src/app/services/task.service';
@@ -13,7 +13,7 @@ import { TaskService } from 'src/app/services/task.service';
export class AllProcessesPage implements OnInit {
skeletonLoader = false;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
hideSearchBtn: boolean = false;
showSearch = false;
searchSubject: string = '';
@@ -1,6 +1,6 @@
import { Component, OnInit} from '@angular/core';
import { customTask} from '../../../models/dailyworktask.model';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { NavigationStart, Router } from '@angular/router';
import { DespachosprStore } from 'src/app/store/despachospr-store.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
@@ -20,7 +20,7 @@ export class DespachosPrPage implements OnInit {
customTaskPipe = new CustomTaskPipe()
skeletonLoader = false
loggeduser: LoginUserRespose;
loggeduser: UserSession;
despachosprstore = DespachosprStore;
environment = environment
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
@@ -1,7 +1,7 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { ProcessesService } from 'src/app/services/processes.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
@@ -25,7 +25,7 @@ export class ExpedientesPrPage implements OnInit {
customTaskPipe = new CustomTaskPipe()
expedienteTaskPipe = new ExpedienteTaskPipe()
loggeduser: LoginUserRespose;
loggeduser: UserSession;
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
showSearch = false
@@ -9,7 +9,7 @@ import { ModalController } from '@ionic/angular';
import { DocumentSetUpMeetingPage } from 'src/app/modals/document-set-up-meeting/document-set-up-meeting.page';
import { HeaderSettingsService } from "src/app/services/header-settings.service"
import { SessionStore } from 'src/app/store/session.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@@ -33,7 +33,7 @@ export class TaskDetailsPage implements OnInit {
selectedIndex = 0
dropButton = true
loggeduser: LoginUserRespose;
loggeduser: UserSession;
@ViewChild('text', { static: false }) text: ElementRef;
constructor(
@@ -4,7 +4,7 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { customTask} from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { PendentesStore } from 'src/app/store/pendestes-store.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { SortService } from 'src/app/services/functions/sort.service';
import { Storage } from '@ionic/storage';
@@ -22,7 +22,7 @@ export class PendentesPage implements OnInit {
skeletonLoader: boolean = false;
pendentesstore = PendentesStore;
customTaskPipe = new CustomTaskPipe()
loggeduser: LoginUserRespose;
loggeduser: UserSession;
listToPresent = [];
@Input() profile:string;
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
@@ -40,7 +40,7 @@ export class OptsExpedientePrPage implements OnInit {
showEnviarPendentes = false;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
constructor(
private popoverController: PopoverController,
+2 -2
View File
@@ -18,7 +18,7 @@ import {
} from 'angular-calendar';
import { CustomDateFormatter } from './custom-date-formatter.provider';
import { NewEventPage } from './modal/new-event/new-event.page';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { DateAdapter } from '@angular/material/core';
import { eventSource } from 'src/app/models/agenda/eventSource';
import { CalendarStore } from 'src/app/store/calendar.service';
@@ -166,7 +166,7 @@ export class AgendaPage implements OnInit {
*/
IsEvent: "edit" | "add" | "view";
viewingEventObject: CalendarEvent;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
monthNum;
yearNum;
@@ -3,7 +3,7 @@ import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { NavigationEnd, Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { SortService } from 'src/app/services/functions/sort.service';
import { SessionStore } from 'src/app/store/session.service';
import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service';
@@ -33,7 +33,7 @@ export class EventListPage implements OnInit {
eventBody: EventBody;
categories: string[];
serialnumber:string;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
segment:string;
eventoaprovacaostore = EventoAprovacaoStore;
environment = environment
@@ -5,7 +5,7 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList_v2 } from "src/app/models/search-document";
import { ToastService } from 'src/app/services/toast.service';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { DateAdapter } from '@angular/material/core';
import * as _moment from 'moment';
import * as _rollupMoment from 'moment';
@@ -89,7 +89,7 @@ export class NewEventPage implements OnInit {
documents: SearchList_v2[] = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
Form: FormGroup;
@@ -3,7 +3,7 @@ import { ModalController, NavParams, Platform } from '@ionic/angular';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { SearchList } from 'src/app/models/search-document';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { Event } from '../../../../models/event.model';
import { AttendeesPageModal } from '../../../../pages/events/attendees/attendees.page';
@@ -94,7 +94,7 @@ export class NewEventPage implements OnInit {
documents: SearchList[] = [];
loggeduser: LoginUserRespose;
loggeduser: UserSession;
members: any;
CalendarName;
SessionStore = SessionStore;
@@ -86,7 +86,7 @@ export class InactivityPage implements OnInit {
// if current attemp is equal to the current user
if (attempt.UserId == SessionStore.user.wxUserId) {
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt, this.userattempt);
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
// this.authService.loginChat();
@@ -101,7 +101,7 @@ export class InactivityPage implements OnInit {
window.localStorage.clear();
SessionStore.setInativity(true)
await this.authService.SetSession(attempt, this.userattempt);
// await this.authService.SetSession(attempt, this.userattempt);
}
this.enterWithPassword = false
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service';
import { SessionStore } from 'src/app/store/session.service';
@@ -10,7 +10,7 @@ import { SessionStore } from 'src/app/store/session.service';
})
export class HeaderPrPage implements OnInit {
loggeduser: LoginUserRespose;
loggeduser: UserSession;
constructor(authService: AuthService) {
this.loggeduser = SessionStore.user;
@@ -2,7 +2,7 @@ import { Component, OnInit, ChangeDetectorRef, NgZone } from '@angular/core';
import { AnimationController, ModalController, Platform } from '@ionic/angular';
import { SearchPage } from 'src/app/pages/search/search.page';
import { Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model';
import { UserSession } from 'src/app/models/user.model';
import { ProfilePage } from 'src/app/modals/profile/profile.page';
import { StorageService } from '../../../../services/storage.service';
import { SessionStore } from 'src/app/store/session.service';
@@ -33,7 +33,7 @@ export class HeaderPage implements OnInit {
searchSubject: string = '';
showSearch = false;
loggeduser: LoginUserRespose;
loggeduser: UserSession;
hideSearchBtn: boolean = false;
notificationdata: any[] = [];
DataArray: Array<object> = [];
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "33520fc75",
"SHA": "33520fc758c4a603c67083c152a9863e647728c8",
"shortSHA": "5c0bd094c",
"SHA": "5c0bd094ca5cb379aa625187cc5afb47f576ffec",
"branch": "feature/login-v2",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Wed Nov 6 09:16:35 2024 +0100'",
"lastCommitMessage": "remove userId",
"lastCommitNumber": "6126",
"changeStatus": "On branch feature/login-v2\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/services/monitoring/opentelemetry/tracer.ts\n\tmodified: src/app/ui/chat/component/group-contacts/group-contacts.page.html\n\tmodified: src/app/ui/chat/modal/group-contacts/group-contacts.page.html\n\tmodified: version/git-version.ts",
"lastCommitTime": "'Wed Nov 6 09:20:31 2024 +0100'",
"lastCommitMessage": "remove userName",
"lastCommitNumber": "6127",
"changeStatus": "On branch feature/login-v2\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/user/entity/userEntity.ts\n\tnew file: src/app/core/user/mapper/user-login.ts\n\tmodified: src/app/core/user/repository/user-remote-repository.ts\n\tmodified: src/app/core/user/use-case/user-login-use-case.service.ts\n\tmodified: src/app/modals/create-process/create-process.page.ts\n\tmodified: src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n\tmodified: src/app/models/user.model.ts\n\tmodified: src/app/pages/events/attendees/attendees.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts\n\tmodified: src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/expedientes-pr/expedientes-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts\n\tmodified: src/app/pages/gabinete-digital/pendentes/pendentes.page.ts\n\tmodified: src/app/pages/inactivity/inactivity.page.ts\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/services/attachments.service.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/services/organic-entity.service.ts\n\tmodified: src/app/services/processes.service.ts\n\tmodified: src/app/services/publications.service.ts\n\tmodified: src/app/services/search.service.ts\n\tmodified: src/app/shared/event/attendee-modal/attendee-modal.page.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/shared/gabinete-digital/expedientes-pr/expedientes-pr.page.ts\n\tmodified: src/app/shared/gabinete-digital/generic/task-details/task-details.page.ts\n\tmodified: src/app/shared/gabinete-digital/pendentes/pendentes.page.ts\n\tmodified: src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts\n\tmodified: src/app/ui/agenda/agenda.page.ts\n\tmodified: src/app/ui/agenda/component/event-list/event-list.page.ts\n\tmodified: src/app/ui/agenda/component/new-event/new-event.page.ts\n\tmodified: src/app/ui/agenda/modal/new-event/new-event.page.ts\n\tmodified: src/app/ui/login/inactivity/inactivity.page.ts\n\tmodified: src/app/ui/shared/components/header-pr/header-pr.page.ts\n\tmodified: src/app/ui/shared/components/header/header.page.ts",
"changeAuthor": "peter.maquiran"
}