mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
1 line
23 KiB
JSON
1 line
23 KiB
JSON
{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./login.page.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./login.page.scss?ngResource\";\nimport { Component } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ToastService } from 'src/app/services/toast.service';\nimport { environment } from 'src/environments/environment';\nimport { AlertController } from '@ionic/angular';\nimport { NotificationsService } from 'src/app/services/notifications.service';\nimport { SessionStore } from 'src/app/store/session.service';\nimport { ClearStoreService } from 'src/app/services/clear-store.service';\nimport { ChangeProfileService } from 'src/app/services/change-profile.service';\nimport { ThemeService } from 'src/app/services/theme.service';\nimport { PermissionService } from 'src/app/services/permission.service';\nimport { MessageModel, DeleteMessageModel } from '../../models/beast-orm';\nimport { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';\nimport { ChatSystemService } from 'src/app/services/chat/chat-system.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { Platform } from '@ionic/angular';\nimport { FirstEnterService } from '../../services/first-enter.service';\nimport { Storage } from '@ionic/storage';\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\nlet LoginPage = class LoginPage {\n constructor(notificatinsservice, router, authService, toastService, alertController, clearStoreService, changeProfileService, ThemeService, p, RochetChatConnectorService, ChatSystemService, ChatService, platform, FirstEnterService, storage, httpErrorHandle) {\n this.notificatinsservice = notificatinsservice;\n this.router = router;\n this.authService = authService;\n this.toastService = toastService;\n this.alertController = alertController;\n this.clearStoreService = clearStoreService;\n this.changeProfileService = changeProfileService;\n this.ThemeService = ThemeService;\n this.p = p;\n this.RochetChatConnectorService = RochetChatConnectorService;\n this.ChatSystemService = ChatSystemService;\n this.ChatService = ChatService;\n this.platform = platform;\n this.FirstEnterService = FirstEnterService;\n this.storage = storage;\n this.httpErrorHandle = httpErrorHandle;\n this.username = SessionStore.user.Email || environment.defaultuser;\n this.password = environment.defaultuserpwd;\n this.code = [];\n this.sessionStore = SessionStore;\n this.showPassword = false;\n this.passwordIcon = \"eye\";\n }\n ngOnInit() {}\n togglePassword() {\n this.showPassword = !this.showPassword;\n if (this.passwordIcon == \"eye\") {\n this.passwordIcon = \"eye-off\";\n } else {\n this.passwordIcon = \"eye\";\n }\n }\n //Function to validade the login inputs\n validateUsername() {\n return this.username.trim().length > 0;\n }\n validatePassword() {\n return this.password.trim().length > 0;\n }\n presentAlert(message) {\n var _this = this;\n return _asyncToGenerator(function* () {\n const alert = yield _this.alertController.create({\n cssClass: 'my-custom-class',\n header: 'Mensagem do sistema',\n message: message,\n buttons: ['OK']\n });\n yield alert.present();\n })();\n }\n getToken() {\n this.notificatinsservice.requestPermissions();\n this.notificatinsservice.registrationError();\n this.notificatinsservice.getAndpostToken(this.username);\n }\n Login() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n if (_this2.validateUsername()) {\n if (_this2.validatePassword()) {\n _this2.userattempt = {\n username: _this2.username.trim(),\n password: _this2.password.trim(),\n domainName: environment.domain,\n BasicAuthKey: \"\"\n };\n const loader = _this2.toastService.loading();\n let attempt = yield _this2.authService.login(_this2.userattempt, {\n saveSession: false\n });\n loader.remove();\n if (attempt) {\n if (attempt.UserId == SessionStore.user.UserId) {\n yield _this2.authService.SetSession(attempt, _this2.userattempt);\n _this2.changeProfileService.run();\n if (attempt.ChatData) {\n yield _this2.authService.loginToChatWs();\n _this2.ChatService.setheader();\n _this2.ChatSystemService.loadChat();\n }\n _this2.changeProfileService.runLogin();\n _this2.getToken();\n SessionStore.setInativity(true);\n _this2.goback();\n } else {\n _this2.RochetChatConnectorService.logout();\n _this2.clearStoreService.clear();\n _this2.ChatSystemService.clearChat();\n SessionStore.delete();\n window.localStorage.clear();\n yield MessageModel.deleteAll();\n yield DeleteMessageModel.deleteAll();\n _this2.storage.clear();\n yield _this2.authService.SetSession(attempt, _this2.userattempt);\n _this2.changeProfileService.run();\n if (attempt.ChatData) {\n yield _this2.authService.loginToChatWs();\n _this2.ChatService.setheader();\n _this2.ChatSystemService.loadChat();\n }\n _this2.getToken();\n if (!_this2.platform.is('desktop') && !_this2.platform.is('mobileweb')) {\n if (_this2.sessionStore.hasPin) {\n _this2.router.navigateByUrl('/home/events');\n } else {\n _this2.router.navigateByUrl('/pin', {\n replaceUrl: true\n });\n }\n } else {\n _this2.router.navigate(['/home/events']);\n }\n }\n } /*\r\n else{\r\n this.toastService._badRequest('Ocorreu um problema por favor valide o username e password');\r\n } */\n } else {\n _this2.toastService._badRequest('Por favor, insira a sua palavra-passe');\n }\n } else {\n _this2.toastService._badRequest('Por favor, insira o seu nome de utilizador');\n }\n })();\n }\n goback() {\n const pathName = SessionStore.user.UrlBeforeInactivity;\n if (pathName) {\n this.router.navigate([pathName]);\n } else {\n if (this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {\n //When user has got access to Agenda but does not have their own calendar, goes to Agenda\n if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0) {\n this.router.navigate(['/home/agenda']);\n } else {\n this.router.navigate(['/home/events']);\n }\n }\n //If user has access permission to both Chat and Action, goes to Chat by default.\n else if (this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access) || this.p.userPermission(this.p.permissionList.Chat.access)) {\n this.router.navigate(['/home/chat']);\n } else if (this.p.userPermission(this.p.permissionList.Actions.access)) {\n this.router.navigate(['/home/publications']);\n }\n }\n }\n};\nLoginPage.ctorParameters = () => [{\n type: NotificationsService\n}, {\n type: Router\n}, {\n type: AuthService\n}, {\n type: ToastService\n}, {\n type: AlertController\n}, {\n type: ClearStoreService\n}, {\n type: ChangeProfileService\n}, {\n type: ThemeService\n}, {\n type: PermissionService\n}, {\n type: RochetChatConnectorService\n}, {\n type: ChatSystemService\n}, {\n type: ChatService\n}, {\n type: Platform\n}, {\n type: FirstEnterService\n}, {\n type: Storage\n}, {\n type: HttpErrorHandle\n}];\nLoginPage = __decorate([Component({\n selector: 'app-login',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], LoginPage);\nexport { LoginPage };","map":{"version":3,"mappings":";;;;AAAA,SAASA,SAAS,QAAgB,eAAe;AACjD,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,WAAW,QAAQ,+BAA+B;AAE3D,SAASC,YAAY,QAAQ,gCAAgC;AAC7D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,oBAAoB,QAAQ,yCAAyC;AAC9E,SAASC,YAAY,QAAQ,gCAAgC;AAC7D,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,wBAAwB;AACzE,SAASC,0BAA0B,QAAQ,qDAAqD;AAChG,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,iBAAiB,QAAQ,oCAAoC;AACtE,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,eAAe,QAAQ,4CAA4C;AAMrE,IAAMC,SAAS,GAAf,MAAMA,SAAS;EAepBC,YACUC,mBAAyC,EACzCC,MAAc,EACdC,WAAwB,EACxBC,YAA0B,EAC3BC,eAAgC,EAC/BC,iBAAoC,EACpCC,oBAA0C,EAC3CnB,YAA0B,EAC1BoB,CAAoB,EACnBhB,0BAAsD,EACvDC,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AACvE,MAAM,CAACuE,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC;;;MAG1C;MAAA,KACK,IAAI,IAAI,CAACjE,CAAC,CAACqE,cAAc,CAAC,IAAI,CAACrE,CAAC,CAACsE,cAAc,CAACK,IAAI,CAACH,MAAM,CAAC,IAAI,IAAI,CAACxE,CAAC,CAACqE,cAAc,CAAC,IAAI,CAACrE,CAAC,CAACsE,cAAc,CAACM,OAAO,CAACJ,MAAM,CAAC,IAAK,IAAI,CAACxE,CAAC,CAACqE,cAAc,CAAC,IAAI,CAACrE,CAAC,CAACsE,cAAc,CAACK,IAAI,CAACH,MAAM,CAAC,EAAC;QAC5L,IAAI,CAAC9E,MAAM,CAACuE,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;OACrC,MACI,IAAG,IAAI,CAACjE,CAAC,CAACqE,cAAc,CAAC,IAAI,CAACrE,CAAC,CAACsE,cAAc,CAACM,OAAO,CAACJ,MAAM,CAAC,EAAC;QAClE,IAAI,CAAC9E,MAAM,CAACuE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,CAAC;;;EAIlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAjMW1E,SAAS,eALrBrB,SAAS,CAAC;EACT2G,QAAQ,EAAE,WAAW;EACrBC,8BAAgC;;CAEjC,CAAC,GACWvF,SAAS;SAATA,SAAS","names":["Component","Router","AuthService","ToastService","environment","AlertController","NotificationsService","SessionStore","ClearStoreService","ChangeProfileService","ThemeService","PermissionService","MessageModel","DeleteMessageModel","RochetChatConnectorService","ChatSystemService","ChatService","Platform","FirstEnterService","Storage","HttpErrorHandle","LoginPage","constructor","notificatinsservice","router","authService","toastService","alertController","clearStoreService","changeProfileService","p","platform","storage","httpErrorHandle","user","Email","defaultuser","defaultuserpwd","ngOnInit","togglePassword","showPassword","passwordIcon","validateUsername","username","trim","length","validatePassword","password","presentAlert","message","alert","_this","create","cssClass","header","buttons","present","getToken","requestPermissions","registrationError","getAndpostToken","Login","_this2","userattempt","domainName","domain","BasicAuthKey","loader","loading","attempt","login","saveSession","remove","UserId","SetSession","run","ChatData","loginToChatWs","setheader","loadChat","runLogin","setInativity","goback","logout","clear","clearChat","delete","window","localStorage","deleteAll","is","sessionStore","hasPin","navigateByUrl","replaceUrl","navigate","_badRequest","pathName","UrlBeforeInactivity","userPermission","permissionList","Agenda","access","Gabinete","OwnerCalendars","Chat","Actions","selector","template"],"sourceRoot":"","sources":["C:\\Users\\eudes.inacio\\GabineteDigital\\gabinete-digital-fo\\src\\app\\pages\\login\\login.page.ts"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\r\nimport { Router } from '@angular/router';\r\nimport { AuthService } from 'src/app/services/auth.service';\r\nimport { UserForm } from 'src/app/models/user.model';\r\nimport { ToastService } from 'src/app/services/toast.service';\r\nimport { environment } from 'src/environments/environment';\r\nimport { AlertController } from '@ionic/angular';\r\nimport { NotificationsService } from 'src/app/services/notifications.service';\r\nimport { SessionStore } from 'src/app/store/session.service';\r\nimport { ClearStoreService } from 'src/app/services/clear-store.service';\r\nimport { ChangeProfileService } from 'src/app/services/change-profile.service';\r\nimport { ThemeService } from 'src/app/services/theme.service';\r\nimport { PermissionService } from 'src/app/services/permission.service';\r\nimport { MessageModel, DeleteMessageModel } from '../../models/beast-orm';\r\nimport { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';\r\nimport { ChatSystemService } from 'src/app/services/chat/chat-system.service';\r\nimport { ChatService } from 'src/app/services/chat.service';\r\nimport { Platform } from '@ionic/angular';\r\nimport { FirstEnterService } from '../../services/first-enter.service';\r\nimport { Storage } from '@ionic/storage';\r\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\r\n@Component({\r\n selector: 'app-login',\r\n templateUrl: './login.page.html',\r\n styleUrls: ['./login.page.scss'],\r\n})\r\nexport class LoginPage implements OnInit {\r\n\r\n logstatus: boolean;\r\n username: string = SessionStore.user.Email || environment.defaultuser;\r\n password: string = environment.defaultuserpwd;\r\n userattempt: UserForm;\r\n code = []\r\n\r\n hasPin: boolean\r\n loginPreference: string\r\n\r\n sessionStore = SessionStore;\r\n showPassword = false;\r\n passwordIcon = \"eye\";\r\n\r\n constructor(\r\n private notificatinsservice: NotificationsService,\r\n private router: Router,\r\n private authService: AuthService,\r\n private toastService: ToastService,\r\n public alertController: AlertController,\r\n private clearStoreService: ClearStoreService,\r\n private changeProfileService: ChangeProfileService,\r\n public ThemeService: ThemeService,\r\n public p: PermissionService,\r\n private RochetChatConnectorService: RochetChatConnectorService,\r\n public ChatSystemService: ChatSystemService,\r\n private ChatService: ChatService,\r\n private platform: Platform,\r\n private FirstEnterService: FirstEnterService,\r\n private storage:Storage,\r\n private httpErrorHandle: HttpErrorHandle\r\n ) {}\r\n\r\n ngOnInit() {}\r\n\r\n togglePassword() {\r\n this.showPassword = !this.showPassword;\r\n\r\n if(this.passwordIcon == \"eye\") {\r\n this.passwordIcon = \"eye-off\";\r\n } else {\r\n this.passwordIcon = \"eye\";\r\n }\r\n\r\n }\r\n\r\n //Function to validade the login inputs\r\n validateUsername() {\r\n return (\r\n this.username.trim().length > 0\r\n );\r\n }\r\n\r\n validatePassword() {\r\n return (\r\n this.password.trim().length > 0\r\n );\r\n }\r\n\r\n async presentAlert(message: string) {\r\n const alert = await this.alertController.create({\r\n cssClass: 'my-custom-class',\r\n header: 'Mensagem do sistema',\r\n message: message,\r\n buttons: ['OK']\r\n });\r\n\r\n \r\n await alert.present();\r\n }\r\n\r\n getToken() {\r\n this.notificatinsservice.requestPermissions();\r\n this.notificatinsservice.registrationError();\r\n this.notificatinsservice.getAndpostToken(this.username);\r\n }\r\n\r\n async Login() {\r\n\r\n\r\n if (this.validateUsername()) {\r\n if(this.validatePassword()) {\r\n\r\n this.userattempt = {\r\n username: this.username.trim(),\r\n password: this.password.trim(),\r\n domainName: environment.domain,\r\n BasicAuthKey: \"\"\r\n }\r\n\r\n const loader = this.toastService.loading()\r\n\r\n let attempt = await this.authService.login(this.userattempt, {saveSession: false})\r\n\r\n loader.remove()\r\n\r\n if (attempt) {\r\n if (attempt.UserId == SessionStore.user.UserId) {\r\n\r\n await this.authService.SetSession(attempt, this.userattempt);\r\n this.changeProfileService.run();\r\n\r\n if(attempt.ChatData) {\r\n \r\n await this.authService.loginToChatWs();\r\n this.ChatService.setheader()\r\n this.ChatSystemService.loadChat();\r\n \r\n }\r\n \r\n this.changeProfileService.runLogin();\r\n this.getToken();\r\n SessionStore.setInativity(true);\r\n\r\n this.goback();\r\n\r\n } else {\r\n\r\n \r\n this.RochetChatConnectorService.logout();\r\n this.clearStoreService.clear();\r\n this.ChatSystemService.clearChat();\r\n SessionStore.delete();\r\n window.localStorage.clear();\r\n await MessageModel.deleteAll();\r\n await DeleteMessageModel.deleteAll();\r\n this.storage.clear();\r\n\r\n await this.authService.SetSession(attempt, this.userattempt);\r\n this.changeProfileService.run();\r\n\r\n \r\n if(attempt.ChatData) {\r\n await this.authService.loginToChatWs();\r\n this.ChatService.setheader();\r\n this.ChatSystemService.loadChat();\r\n }\r\n\r\n this.getToken();\r\n\r\n if(!this.platform.is('desktop') && !this.platform.is('mobileweb')) {\r\n if(this.sessionStore.hasPin) {\r\n this.router.navigateByUrl('/home/events');\r\n } else {\r\n this.router.navigateByUrl('/pin', { replaceUrl: true });\r\n }\r\n \r\n } else {\r\n this.router.navigate(['/home/events']);\r\n }\r\n\r\n \r\n }\r\n }/* \r\n else{\r\n this.toastService._badRequest('Ocorreu um problema por favor valide o username e password');\r\n } */\r\n }\r\n else {\r\n this.toastService._badRequest('Por favor, insira a sua palavra-passe');\r\n }\r\n }\r\n else {\r\n this.toastService._badRequest('Por favor, insira o seu nome de utilizador');\r\n }\r\n\r\n\r\n }\r\n\r\n goback() {\r\n const pathName = SessionStore.user.UrlBeforeInactivity\r\n if(pathName) {\r\n this.router.navigate([pathName]);\r\n } else {\r\n if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){\r\n //When user has got access to Agenda but does not have their own calendar, goes to Agenda\r\n if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){\r\n this.router.navigate(['/home/agenda']);\r\n }\r\n else{\r\n this.router.navigate(['/home/events']);\r\n }\r\n }\r\n //If user has access permission to both Chat and Action, goes to Chat by default.\r\n else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){\r\n this.router.navigate(['/home/chat']);\r\n }\r\n else if(this.p.userPermission(this.p.permissionList.Actions.access)){\r\n this.router.navigate(['/home/publications']);\r\n }\r\n }\r\n\r\n }\r\n\r\n}\r\n"]},"metadata":{},"sourceType":"module"} |