Files
Kavita/UI/Web/src/app/_interceptors/jwt.interceptor.ts
T
Joe Milazzo 0bbb0ff28f Massive UI Cleanup (#4466)
Co-authored-by: KindlyFire <10267586+kindlyfire@users.noreply.github.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Adam Havránek <adamhavra@seznam.cz>
Co-authored-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com>
Co-authored-by: Alexey <lewadedun@gmail.com>
Co-authored-by: Anon Bitardov <timurvolga23+weblate@gmail.com>
Co-authored-by: Ferran <ferrancette@gmail.com>
Co-authored-by: Gneb <goozi12345@gmail.com>
Co-authored-by: Robin Stolpe <robinstolpe@slashmad.com>
Co-authored-by: 안세훈 <on9686@gmail.com>
Co-authored-by: Tijl Van den Brugghen <contact@tijlvdb.me>
2026-02-28 11:19:00 -08:00

19 lines
470 B
TypeScript

import {inject} from '@angular/core';
import {HttpInterceptorFn} from '@angular/common/http';
import {AccountService} from '../_services/account.service';
export const jwtInterceptor: HttpInterceptorFn = (req, next) => {
const accountService = inject(AccountService);
const user = accountService.currentUser();
if (user?.token) {
req = req.clone({
setHeaders: {
Authorization: `Bearer ${user.token}`
}
});
}
return next(req);
};