PageSourceSearch

https://ibertronica.es/chunk-53JEHPZS.js

js ibertronica.es collected 2026-09-25 00:10:14 UTC 2,868 bytes, 1 lines download raw bytes

1import{a as k}from"./chunk-TXPUIE7S.js";import{a as A}from"./chunk-SG564UKI.js";import{a as f}from"./chunk-OEPGTP6C.js";import{f as d}from"./chunk-RTBYSEZV.js";import{a as m,e as v,f as u}from"./chunk-B5V7S4C6.js";import{Fa as a}from"./chunk-C7I55XO7.js";import{A as i,O as o,Qc as p,T as h,Y as r,i as s,oa as n,za as l}from"./chunk-QVGDTXHA.js";var g=class c{httpBackend=r(v);httpClient=r(u);authHttpClient=new u(this.httpBackend);cookieService=r(A);router=r(d);translationService=r(f);platformId=r(l);accountService=r(k);currentUser=n(null);accessToken=n(null);isAuthenticated=p(()=>!!this.accessToken());constructor(){let e=this.cookieService.get("access_token");this.accessToken.set(e??null),this.loadUserFromStorage(),a(this.platformId)&&(e?this.reloadUserData():this.accountService.resetAccount())}logout(e){let t=e?.redirect!==!1;if(this.cookieService.delete("access_token","/"),this.cookieService.delete("refresh_token","/"),this.cookieService.delete("user","/"),this.accessToken.set(null),this.currentUser.set(null),this.accountService.resetAccount(),!(!t||!a(this.platformId))){if(this.translationService.getActiveLang()==="en"){this.router.navigate(["/en/login"]);return}this.router.navigate(["/login"])}}login(e){return this.authHttpClient.post("/api/login",{username:e.email,password:e.password},{observe:"response",responseType:"json"}).pipe(o(t=>this.handleAuthResponse(t.body)),i(t=>s(t)))}refreshToken(e){return this.authHttpClient.post("/api/authorize",e).pipe(o(t=>this.handleAuthResponse(t)),i(()=>(this.logout(),s())))}getAccessToken(){return this.accessToken()??this.cookieService.get("access_token")}refreshUserData(e){this.handleAccountResponse(e),this.accountService.setUser(e)}reloadUserData(){this.accountService.resetAccount(),this.authHttpClient.get("/api/account",{headers:new m({Accept:"application/json",Authorization:`Bearer ${this.getAccessToken()}`})}).pipe(o(e=>{this.handleAccountResponse(e),this.accountService.setUser(e)}),i(()=>(this.logout({redirect:!1}),s()))).subscribe()}handleAccountResponse(e){let t={id:e.id,firstName:e.firstName,lastName:e.lastName,fullName:e.fullName,email:e.email,tax:e.tax,customer_id:e.customer?.id};this.currentUser.set(t),this.cookieService.set("user",JSON.stringify(t),{expires:30,path:"/",secure:!0,sameSite:"Lax"})}handleAuthResponse(e){this.cookieService.set("access_token",e.access_token,{expires:1,path:"/",secure:!0,sameSite:"Lax"}),this.cookieService.set("refresh_token",e.refresh_token,{expires:30,path:"/",secure:!0,sameSite:"Lax"}),this.accessToken.set(e.access_token),this.reloadUserData()}loadUserFromStorage(){let e=this.getAccessToken(),t=this.cookieService.get("user");e&&t&&this.currentUser.set(JSON.parse(t))}getUser(){return this.currentUser()}static \u0275fac=function(t){return new(t||c)};static \u0275prov=h({token:c,factory:c.\u0275fac,providedIn:"root"})};export{g as a};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.