make auth resolver standalone

This commit is contained in:
Cucumberrbob 2025-06-07 17:29:52 +01:00
parent 2e7c97d023
commit e48f1d91a4
No known key found for this signature in database
GPG key ID: 2B935C47401C3614
2 changed files with 7 additions and 13 deletions

View file

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AddNewTorrentComponent } from './add-new-torrent/add-new-torrent.component';
import { AuthResolverService } from './auth-resolver.service';
import { authResolver } from './auth-resolver.service';
import { LoginComponent } from './login/login.component';
import { MainLayoutComponent } from './main-layout/main-layout.component';
import { ProfileComponent } from './profile/profile.component';
@ -23,7 +23,7 @@ const routes: Routes = [
path: '',
component: MainLayoutComponent,
resolve: {
isLoggedIn: AuthResolverService,
isLoggedIn: authResolver,
},
children: [
{

View file

@ -1,13 +1,7 @@
import { Injectable } from '@angular/core';
import { inject } from '@angular/core';
import { AuthService } from './auth.service';
import { ResolveFn } from '@angular/router';
@Injectable({
providedIn: 'root',
})
export class AuthResolverService {
constructor(private authService: AuthService) {}
resolve() {
return this.authService.isLoggedIn();
}
}
export const authResolver: ResolveFn<boolean> = () => {
return inject(AuthService).isLoggedIn();
};