mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-06 14:55:19 -04:00
0bbb0ff28f
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>
19 lines
470 B
TypeScript
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);
|
|
};
|