Chocobozzz/PeerTube

View on GitHub
client/src/app/core/routing/user.resolver.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { inject } from '@angular/core'
import { ResolveFn } from '@angular/router'
import { first, map } from 'rxjs'
import { AuthService, AuthUser } from '../auth'

export const userResolver: ResolveFn<AuthUser> = () => {
  const auth = inject(AuthService)

  return auth.userInformationLoaded
    .pipe(first(), map(() => auth.getUser()))
}