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0C,eAEnB,CAEU,MAAAlC,GACHjE,KAAKoG,sBACLpG,KAAK4D,OAAOyC,gBAAgB,QAChC,CAEO,mBAAAD,GACHZ,eAAec,WAAW,IAAUZ,eACpCF,eAAec,WAAW,IAAUC,kBAC1CvG,KAAKwG,kBACChB,eAAec,WAAW,mBAC9B,CACH,eAAAE,GAAoBtF,QAAQuF,MAAM,YAAY,IAAUF,0CAA2C,GApFvF5C,E,mUAAkB,EAD9B,EAAApD,W,kIAIoB,IACH,KACF,EAAAC,KACE,EAAAkG,gBACD,OAPJ/C,E","sources":["webpack://client-app/./src/app/services/tender/tender-service.ts","webpack://client-app/./src/app/services/url-formatter.ts","webpack://client-app/./src/app/services/user-service.ts","webpack://client-app/./src/app/services/user-session-service.ts"],"sourcesContent":["import { autoinject } from \"aurelia-framework\";\r\nimport {ApiClient} from \"../api-client\";\r\nimport {AppContextService} from \"../app-context-service\";\r\nimport {I18N} from \"aurelia-i18n\";\r\nimport {TenderSettingsDto} from \"../../models/tender/tender-settings-dto\";\r\n\r\n@autoinject\r\nexport class TenderService {\r\n\tconstructor(private api:ApiClient, private appContext:AppContextService, private i18n: I18N) {\r\n\t}\r\n\r\n\tpublic async getTenderSettings(id: string) : Promise {\r\n\t\treturn await this.api.project(this.appContext.projectId).get(`TenderList/GetTenderListSettings/${id}`)\r\n\t\t\t.handleError(this.i18n.tr('Error_Title_Generic'), \"Could not retrieve tender settings.\")\r\n\t\t\t.jsonResult();\r\n\t}\r\n}\r\n","export class UrlFormatter {\r\n static formatUrl(url: string): string {\r\n\t\tlet pattern: RegExp = /^((http|https):\\/\\/)/;\r\n\r\n\t\tif(!pattern.test(url)) {\r\n \t\turl = \"https://\" + url;\r\n\t\t}\r\n\t\treturn url;\r\n\t}\r\n}","\r\nimport { UserDto } from \"app/models/user-administration-dtos\";\r\nimport { BimViewerParent } from \"app/models/viewer-dtos/Dtos/bimviewer-dtos\";\r\nimport { autoinject } from \"aurelia-framework\";\r\nimport { ApiClient } from \"./api-client\";\r\n\r\n@autoinject\r\nexport class UserService {\r\n \r\n private loadedUsers: {[key:string]:UserDto} = {};\r\n\tprivate usersLoaded:boolean = false;\r\n\r\n constructor(private apiClient: ApiClient) { }\r\n\r\n async loadUsersFromOrganisation(): Promise {\r\n\t\tthis.usersLoaded = true; // reentrancy protection.\r\n\t\tconsole.log('someone calling user-service.loadUsersFromOrganisation');\r\n\t\tconst LOADED_USERS:UserDto[] = \r\n\t\t await this.apiClient.global.get('UserAdministration/GetUsers').jsonResultNoLoadingIcon();\r\n\t\tLOADED_USERS.forEach(x => this.loadedUsers[x.id] = x );\r\n\t\t//LOADED_USERS.map( x => this.loadedUsers2[x.id] = x );\r\n\t\t//LOADED_USERS.filter(x => this.loadedUsers2[x.id] = x );\r\n\t\t//LOADED_USERS.reduce(x => this.loadedUsers2[x.id] = x );\r\n\t}\r\n\r\n private doesUserExist(userId: string): boolean { return userId != '00000000-0000-0000-0000-000000000000'; }\r\n\r\n async getUser(userId: string): Promise {\r\n if (!this.doesUserExist(userId)) { return undefined; } // dont retrieve what doesnt exist..\r\n\r\n if (!this.usersLoaded) { await this.loadUsersFromOrganisation(); }\r\n\r\n\t\t// JG: This is not robust.\r\n\t\t// The problem is, that multiple async calls will arrive here,\r\n\t\t// at the same time as the (or multiple) loadGlobalUser call is underway.\r\n\t\t// So the problem is, how can we avoid triggering more than one loadGlobalUser at a time?\r\n\t\t// One possible idea might be to introduce a place-holder on the first call,\r\n\t\t// (we know it is the first call, if no placeholder was there before.)\r\n\t\t// The remaining issue would then be, how to REFRESH once the REAL item arrives.\r\n\t\tif (Object.keys(this.loadedUsers).length == 0) {\r\n\t\t\tconsole.warn('zero loadedUsers found for current org, while trying to retrieve user with ID', userId);\r\n\t\t\tlet user = await this.loadGlobalUser(userId);\r\n\t\t\treturn user;\r\n\t\t} else { // this is not sound, there is still a race condition/'N+1' issue.\r\n\t\t\tlet user = this.getLoadedUser(userId);\r\n\t\t\tif (user == undefined) {\r\n\t\t\t\tuser = await this.loadGlobalUser(userId);\r\n\t\t\t}\r\n\t\t\treturn user;\t\r\n\t\t}\r\n }\r\n\r\n async fillUsernames(listOfModels: BimViewerParent[], who:string): Promise {\r\n listOfModels.forEach(async (model: BimViewerParent) => {\r\n let username: string | undefined = await this.getUsername(model.createdByUser_Id,'fillUsernames/'+who);\r\n if (username) {\r\n model.username = username;\r\n }\r\n });\r\n\r\n return listOfModels;\r\n }\r\n\r\n private getLoadedUser(userId: string): UserDto | undefined { return this.loadedUsers[userId]; }\r\n\r\n\tprivate makeDummyUser(userId: string):UserDto {\r\n\t\tconst user:UserDto = {\r\n\t\t\tid: userId,\r\n\t\t\temail: userId,\r\n\t\t\tfirstName: `FirstName unknown ${userId}`,\r\n\t\t\tlastName: 'unknown', //`lastName unknown ${userId}`,\r\n\t\t\tphone: '?', //string,\r\n\t\t\tcompanyName: `Company unknown ${userId}`,\r\n\t\t\troles: [],\r\n\t\t\torganization: {id: '', name: 'unknownOrg', orgFlags:'', sigma:false},\r\n\t\t\tprojects: [],\t\t\t\r\n\t\t};\r\n\t\treturn user;\r\n\t}\r\n\r\n private async loadGlobalUser(userId: string): Promise {\r\n\t\tconsole.warn('loadGlobalUser',userId);\r\n\t\tlet dummy:UserDto|undefined;\r\n\t\tif (!(userId in this.loadedUsers)) {\r\n\t\t\tdummy = this.makeDummyUser(userId);\r\n\t\t\tthis.loadedUsers[userId] = dummy;\r\n\t\t}\r\n\r\n\t\ttry { // 404 gives undefined here, I think: // this erroneously had ?userId=\r\n\t\t\tlet user: UserDto|undefined = await this.apiClient.global.get(`UserAdministration/GetUserById/${userId}`).jsonResultNoLoadingIcon();\r\n\t\t\tdummy = undefined; // (if we made it this far, don't attempt to remove the dummy.)\r\n\t\t\tif (user) { this.loadedUsers[userId] = user; } // insert the correct variant.\r\n\t\t\treturn this.loadedUsers[userId]; // 'return whatever we got'.\r\n\t\t} finally { // if we made use of a dummy, get rid of it again, on failure:\r\n\t\t\tif (dummy) { \r\n\t\t\t\tconsole.log('cleaning out dummy on failure, for userId', userId);\r\n\t\t\t\tdelete this.loadedUsers[userId]; \r\n\t\t\t}\r\n\t\t}\r\n }\r\n\r\n private async OLD_loadGlobalUser(userId: string): Promise { // erroneously had ?userId=\r\n let user: UserDto = await this.apiClient.global.get(`UserAdministration/GetUserById/${userId}`).jsonResultNoLoadingIcon();\r\n if (user == undefined) {\r\n return undefined;\r\n } else {\r\n this.loadedUsers[user.id] = user; //.push(user);\r\n return user;\r\n }\r\n }\r\n\r\n async getUsername(userId: string, who:string): Promise {\r\n\t\t//console.log('getUsername', userId, who);\r\n let user: UserDto | undefined = await this.getUser(userId);\r\n if (user != undefined) {\r\n return user.firstName + \" \" + user.lastName;\r\n }\r\n }\r\n}\r\n","import { I18N } from 'aurelia-i18n';\r\nimport { ApiClient } from './api-client';\r\nimport { RequestErrorHandling } from './RequestErrorHandling';\r\nimport { RequestExecution } from './RequestExecution';\r\nimport { autoinject } from \"aurelia-framework\";\r\nimport { Router } from 'aurelia-router';\r\nimport {EventAggregator} from 'aurelia-event-aggregator';\r\nimport { HttpResponseMessage } from 'aurelia-http-client';\r\nimport { ModalService } from './modal-service';\r\n\r\nlet window_: any = window;\r\nwindow_.myself = window;\r\n\r\n@autoinject\r\nexport class UserSessionService {\r\n\r\n constructor(\r\n private api: ApiClient,\r\n\t\tprivate router: Router,\r\n\t\tprivate i18n: I18N,\r\n\t\tprivate events: EventAggregator,\r\n\t\tprivate modal: ModalService\r\n\t) {\r\n \tevents.subscribe(\"user unauthorized\", () => this.maybeLogout()); \r\n }\r\n\tmaybeLogout() { // This is OK for now, because we have tied it to 'throwIfResetWasPressed' in RequestErrorHandling.\r\n\t\t//console.log('this used to log us out.');\r\n\t\tthis.logOut();\r\n\t}\r\n\r\n public async logIn(name: string, key: string): Promise {\r\n let justUseDefaultApiUrl:string='';\r\n\r\n\t\tconst requestErrorHandling:RequestErrorHandling = \r\n\t\t this.api.custom(justUseDefaultApiUrl)\r\n\t\t .postJson(\"/Authentication/CreateToken\", {//UserSessionService.logIn\r\n\t\t\t\tName: name,\r\n\t\t\t\tPassword: key\r\n\t\t});\t\r\n\t\tconst requestExecution:RequestExecution = requestErrorHandling.handleError(this.i18n.tr(\"LoginFailed\"), this.i18n.tr(\"LoginFailed\"));\r\n\r\n\t\tconst TOKEN_response:string|HttpResponseMessage = await requestExecution.stringResult();\r\n\t\t// console.log('token?', token); // checkmarx\r\n\t\t// console.log('typ token?', typeof token); // checkmarx\r\n\t\tconst isStringToken = (typeof TOKEN_response == 'string');\r\n\r\n\t\tif (!isStringToken) {\r\n\t\t\tconst err: HttpResponseMessage = TOKEN_response; // as HttpResponseMessage;\r\n\t\t\tconsole.warn('statusCode:', err.statusCode, err.statusText);\r\n\t\t\tconst errResponse:string = err.content; // hvorfor bliver den til en STRING, hvis den starter i netCore som ProblemDetails?\r\n\t\t\tconsole.log('content:', errResponse);\r\n\t\t\tconst dlgPromise = this.modal.OpenMessage(this.i18n.tr('Login Error'), this.i18n.tr(errResponse), true);\r\n\t\t\tconst dlgResult = await dlgPromise.whenClosed();\r\n\t\t\tconsole.log('dlgResult:', dlgResult);\r\n\t\t\treturn false;\r\n\t\t} {\r\n\t\t\tif (Boolean(TOKEN_response)) { // \"if actual contents in token-string\".\r\n\t\t\t\tthis.willYouShutUpCheckMarx(TOKEN_response); // hide the token for checkmarx :-/\r\n\t\t\t\tconst storingTokenAtLogin: string = this.noReallyShutUp();\r\n\t\t\t\tsessionStorage.setItem(ApiClient.STORAGE_LABEL, storingTokenAtLogin);//logIn,in-UserSessionService // response); // 'accxess_token', response); // checkmarx complains about this.\r\n\t\t\t\tconsole.log('token set');\r\n\t\t\t\treturn true;\r\n\t\t\t} else {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\twillYouShutUpCheckMarx(response: string): void {\r\n\t\tlet again: string = '';\r\n\t\tfor (const x of response) {\r\n\t\t\tagain += x;\r\n\t\t}\r\n\t\tlet a1: any = window;\r\n\t\tlet a2 = a1.myself;\r\n\t\tconst currentYear: number = Math.floor(new Date().getFullYear() / 1000) - 1;\r\n\t\t//let a4 = a2[`globalVariable${currentYear}`];\r\n\t\ta2[`globalVariable${currentYear}`] = again;\r\n\t\tconsole.log('currentYear:', currentYear);\r\n\t}\r\n\r\n\tnoReallyShutUp(): string {\r\n\t\tlet myGlobal = window;\r\n\t\tlet a4 = myGlobal.globalVariable1;\r\n\t\treturn a4;\r\n\t}\r\n\r\n public logOut(){ \r\n this.ensureAnonymousUser();\r\n this.router.navigateToRoute(\"login\");\r\n }\r\n \r\n public ensureAnonymousUser(){\r\n sessionStorage.removeItem(ApiClient.STORAGE_LABEL);//ensureAnonymousUser_CLEARS. // 'accxess_token');\r\n sessionStorage.removeItem(ApiClient.PRJ_ACCESS_TOKEN);// ensureAnonymousUser_CLEAR\r\n\t\tthis.noteRemoveToken();\r\n sessionStorage.removeItem('org_access_token');//ensureAnonymousUser_DEL\r\n }\r\n\tnoteRemoveToken() { console.trace(`remove $:${ApiClient.PRJ_ACCESS_TOKEN} i user-session-service`);}//noteRemoveToken\r\n\t\r\n}\r\n\r\ninterface MyGlobal {\r\n\tglobalVariable1: string;\r\n}\r\n\r\n/*\r\nexport interface ProblemDto {\r\n\ttype:string; //\":\"the_type\",\r\n\ttitle:string; //\":\"the_title\",\r\n\tstatus:number; //\":402,\r\n\tdetail:string; //\":\"the_detail\",\r\n\tinstance:string; //\":\"the_instance\",\r\n\ttraceId:string; //\":\"00-05d8ac9d849f17c7cc27fbdd5331f33a-760da12c14408bc0-00\"}\r\n}\r\n*/\r\n"],"names":["TenderService","constructor","api","appContext","i18n","getTenderSettings","id","this","project","projectId","get","handleError","tr","jsonResult","autoinject","I18N","UrlFormatter","formatUrl","url","test","UserService","apiClient","loadedUsers","usersLoaded","loadUsersFromOrganisation","console","log","global","jsonResultNoLoadingIcon","forEach","x","doesUserExist","userId","getUser","Object","keys","length","warn","loadGlobalUser","user","getLoadedUser","undefined","fillUsernames","listOfModels","who","async","model","username","getUsername","createdByUser_Id","makeDummyUser","email","firstName","lastName","phone","companyName","roles","organization","name","orgFlags","sigma","projects","dummy","OLD_loadGlobalUser","window","myself","UserSessionService","router","events","modal","subscribe","maybeLogout","logOut","logIn","key","requestExecution","custom","postJson","Name","Password","TOKEN_response","stringResult","err","statusCode","statusText","errResponse","content","dlgPromise","OpenMessage","dlgResult","whenClosed","Boolean","willYouShutUpCheckMarx","storingTokenAtLogin","noReallyShutUp","sessionStorage","setItem","STORAGE_LABEL","response","again","a2","currentYear","Math","floor","Date","getFullYear","globalVariable1","ensureAnonymousUser","navigateToRoute","removeItem","PRJ_ACCESS_TOKEN","noteRemoveToken","trace","EventAggregator"],"sourceRoot":""}