DigitalData.UserManager/DigitalData.UserManager.NgWebUI/ClientApp/.angular/cache/17.3.0/babel-webpack/061427284bb0e142ed1b85cca284c315628e8a17d71c66e5272013f55a0485d7.json

1 line
2.9 KiB
JSON

{"ast":null,"code":"import { Observable } from 'rxjs';\nimport Swal from 'sweetalert2';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/router\";\nimport * as i2 from \"@angular/common/http\";\nexport let AuthenticationService = /*#__PURE__*/(() => {\n class AuthenticationService {\n constructor(router, http, loginUrl, logoutUrl, checkUrl) {\n this.router = router;\n this.http = http;\n this.loginUrl = loginUrl;\n this.logoutUrl = logoutUrl;\n this.checkUrl = checkUrl;\n }\n isAuthenticated() {\n return new Observable(observer => {\n this.http.get(this.checkUrl, {\n withCredentials: true\n }).subscribe({\n next: response => {\n _isLogedIn = response.isAuthenticated;\n observer.next(response.isAuthenticated);\n },\n error: error => {\n this.showErrorAlert();\n observer.error(error);\n },\n complete: () => observer.complete()\n });\n });\n }\n login(username, password) {\n return new Observable(observer => {\n const userData = {\n username,\n password\n };\n this.http.post(this.loginUrl, userData, {\n withCredentials: true\n }).subscribe({\n next: response => {\n _isLogedIn = true;\n observer.next(response);\n },\n error: error => {\n this.showErrorAlert();\n observer.error(error);\n },\n complete: () => {\n observer.complete();\n }\n });\n });\n }\n logout() {\n return new Observable(observer => {\n this.http.post(this.logoutUrl, {}, {\n withCredentials: true\n }).subscribe({\n next: response => {\n this.router.navigate(['/']);\n _isLogedIn = false;\n observer.next(response);\n },\n error: error => observer.error(error),\n complete: () => observer.complete()\n });\n });\n }\n showErrorAlert() {\n Swal.fire({\n icon: \"error\",\n title: \"Oops...\",\n text: \"The backend application is not responding.\"\n });\n }\n static #_ = this.ɵfac = function AuthenticationService_Factory(t) {\n return new (t || AuthenticationService)(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i2.HttpClient), i0.ɵɵinject('LOGIN_URL'), i0.ɵɵinject('LOGOUT_URL'), i0.ɵɵinject('LOGIN_CHECK_URL'));\n };\n static #_2 = this.ɵprov = /*@__PURE__*/i0.ɵɵdefineInjectable({\n token: AuthenticationService,\n factory: AuthenticationService.ɵfac,\n providedIn: 'root'\n });\n }\n return AuthenticationService;\n})();\nlet _isLogedIn = false;\nexport const IsLogedIn = () => _isLogedIn;","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}