File

projects/core/src/auth/user-auth/services/auth-redirect-storage.service.ts

Description

Service serves storage role for AuthRedirectService. Used by AuthStatePersistenceService to store redirect url for OAuth flows that rely on redirects.

Index

Properties
Methods

Constructor

constructor()

Methods

getRedirectUrl
getRedirectUrl()

Get redirect url after logging in.

observable with the redirect url as string

setRedirectUrl
setRedirectUrl(redirectUrl: string | undefined)

Set url to redirect to after login.

Parameters :
Name Type Optional
redirectUrl string | undefined No
Returns : void

Properties

Private redirectUrl$
Type : Observable<string | undefined>
Default value : new BehaviorSubject< string | undefined >(undefined)
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';

/**
 * Service serves storage role for AuthRedirectService.
 * Used by AuthStatePersistenceService to store redirect url for OAuth flows that rely on redirects.
 */
@Injectable({
  providedIn: 'root',
})
export class AuthRedirectStorageService {
  constructor() {}

  private redirectUrl$: Observable<string | undefined> = new BehaviorSubject<
    string | undefined
  >(undefined);

  /**
   * Get redirect url after logging in.
   *
   * @returns observable with the redirect url as string
   */
  getRedirectUrl(): Observable<string | undefined> {
    return this.redirectUrl$;
  }

  /**
   * Set url to redirect to after login.
   *
   * @param redirectUrl
   */
  setRedirectUrl(redirectUrl: string | undefined): void {
    (this.redirectUrl$ as BehaviorSubject<string | undefined>).next(
      redirectUrl
    );
  }
}

result-matching ""

    No results matching ""