When looking at this snippet of code:
this.router.navigate(['/login'],{queryParams:{returnUrl:state.url}});
An error is displayed stating that "Property 'url' does not exist on type '(name: string, styles: AnimationStyleMetadata". Below you can find the import statements and a segment of code from an Angular AuthService:
import { Injectable } from "@angular/core";
import { GoogleAuthProvider } from 'firebase/auth';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { Observable } from "rxjs/internal/Observable";
import firebase from 'firebase/compat/app';
import { Router, RouterLink, RouterStateSnapshot } from "@angular/router";
import { startAfter } from "@angular/fire/firestore";
import { state } from "@angular/animations";
@Injectable({ providedIn: 'root' })
export class AuthService {
user$: Observable<firebase.User|null> | undefined;
constructor(private afAuth:AngularFireAuth, private router:Router) {
this.user$ = afAuth.authState;
}
login() {
this.afAuth.signInWithRedirect(new GoogleAuthProvider());
}
logout(){
this.afAuth.signOut();
}
isLoggedIn(){
this.user$?.subscribe(user =>{
if(user) return true;
this.router.navigate(['/login'],{queryParams:{returnUrl: state.url}});
return false;
})
}
}