File

src/modules/session/services/session.service.intf.ts

Description

Stark Session Service. Service to get/set session settings (language, ...).

Index

Properties
Methods

Methods

getCurrentLanguage
getCurrentLanguage()

Gets the session's current language (language Id)

Returns : Observable<string>

Observable that will emit the currentLanguage and the latest value whenever it changes

getCurrentUser
getCurrentUser()

Returns the session's current StarkUser

Returns : Observable<StarkUser | undefined>

Observable that will emit the current user and the latest value whenever it changes

login
login(user: StarkUser)

Performs the login of the given StarkUser. Internally, it performs all the necessary actions to initialize the session.

Parameters :
Name Type Optional Description
user StarkUser No
  • The user to log in.
Returns : void
logout
logout()

Performs the logout of the user. Internally, it performs all the necessary actions to destroy the session.

Returns : void
pauseUserActivityTracking
pauseUserActivityTracking()

Pauses the tracking of user activity. It dispatches a USER_ACTIVITY_TRACKING_PAUSE action to the NGRX-Store

Returns : void
resumeUserActivityTracking
resumeUserActivityTracking()

Resumes the tracking of user activity. It dispatches a USER_ACTIVITY_TRACKING_RESUME action to the NGRX-Store

Returns : void
setCurrentLanguage
setCurrentLanguage(newLanguage: string)

Sets the current session's language (language Id). It dispatches a CHANGE_LANGUAGE action to the NGRX-Store

Parameters :
Name Type Optional Description
newLanguage string No
  • The language Id to be set
Returns : void
setDevAuthenticationHeaders
setDevAuthenticationHeaders(devAuthenticationHeaders: Map)

Add authentication headers to the session They are use by the http service to authenticate the user

Parameters :
Name Type Optional
devAuthenticationHeaders Map<string | string | []> No
Returns : void

Properties

devAuthenticationHeaders
devAuthenticationHeaders: Map<string | string | []>
Type : Map<string | string | []>

Authentication headers necessary for non-production environments

import { InjectionToken } from "@angular/core";
import { Observable } from "rxjs";
import { StarkUser } from "../../user/entities";

/**
 * @ignore
 */
export const starkSessionServiceName = "StarkSessionService";
/**
 * {@link https://v12.angular.io/api/core/InjectionToken|InjectionToken} used to provide the {@link StarkSessionService}
 */
export const STARK_SESSION_SERVICE: InjectionToken<StarkSessionService> = new InjectionToken<StarkSessionService>(starkSessionServiceName);

/**
 * Stark Session Service.
 * Service to get/set session settings (language, ...).
 */
export interface StarkSessionService {
	/**
	 * Authentication headers necessary for non-production environments
	 * @returns A Map containing the development authentication headers
	 */
	readonly devAuthenticationHeaders: Map<string, string | string[]>;

	/**
	 * Returns the session's current {@link StarkUser}
	 *
	 * @returns Observable that will emit the current user and the latest value whenever it changes
	 */
	getCurrentUser(): Observable<StarkUser | undefined>;

	/**
	 * Gets the session's current language (language Id)
	 *
	 * @returns Observable that will emit the currentLanguage and the latest value whenever it changes
	 */
	getCurrentLanguage(): Observable<string>;

	/**
	 * Sets the current session's language (language Id).
	 * It dispatches a CHANGE_LANGUAGE action to the NGRX-Store
	 *
	 * @param newLanguage - The language Id to be set
	 */
	setCurrentLanguage(newLanguage: string): void;

	/**
	 * Performs the login of the given {@link StarkUser}. Internally, it performs all the necessary actions to initialize the session.
	 *
	 * @param user - The user to log in.
	 */
	login(user: StarkUser): void;

	/**
	 * Performs the logout of the user. Internally, it performs all the necessary actions to destroy the session.
	 */
	logout(): void;

	/**
	 * Pauses the tracking of user activity.
	 * It dispatches a USER_ACTIVITY_TRACKING_PAUSE action to the NGRX-Store
	 */
	pauseUserActivityTracking(): void;

	/**
	 * Resumes the tracking of user activity.
	 * It dispatches a USER_ACTIVITY_TRACKING_RESUME action to the NGRX-Store
	 */
	resumeUserActivityTracking(): void;

	/**
	 * Add authentication headers to the session
	 * They are use by the http service to authenticate the user
	 */
	setDevAuthenticationHeaders(devAuthenticationHeaders: Map<string, string | string[]>): void;
}

results matching ""

    No results matching ""