Search Results for

    Show / Hide Table of Contents

    Class AuthenticationStateCache

    Singleton service that caches authentication state across components to improve performance and reduce local storage access.

    Inheritance
    object
    AuthenticationStateCache
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: OEMS.UI.Auth
    Assembly: OEMS.UI.dll
    Syntax
    public class AuthenticationStateCache
    Remarks

    This cache serves several purposes:

    1. Improves performance by avoiding repeated token parsing
    2. Reduces browser local storage access
    3. Ensures consistent auth state across the application
    4. Provides fallback when localStorage is not available

    Constructors

    AuthenticationStateCache()

    Initializes a new instance of the authentication state cache with an unauthenticated state.

    Declaration
    public AuthenticationStateCache()

    Properties

    CachedToken

    Gets the cached authentication token.

    Declaration
    public string CachedToken { get; }
    Property Value
    Type Description
    string

    CurrentState

    Gets or sets the current authentication state.

    Declaration
    public AuthenticationState CurrentState { get; set; }
    Property Value
    Type Description
    AuthenticationState
    Remarks

    This property is used to maintain a consistent auth state across all components in the application.

    HasToken

    Gets a value indicating whether the cache contains a valid token.

    Declaration
    public bool HasToken { get; }
    Property Value
    Type Description
    bool

    Methods

    GetItem(string)

    Retrieves an item from the in-memory cache.

    Declaration
    public string GetItem(string key)
    Parameters
    Type Name Description
    string key

    The key of the item to retrieve

    Returns
    Type Description
    string

    The stored value, or null if not found

    RemoveItem(string)

    Removes an item from the in-memory cache.

    Declaration
    public void RemoveItem(string key)
    Parameters
    Type Name Description
    string key

    The key of the item to remove

    Remarks

    Special handling for the "authToken" key to maintain consistency of the authentication state.

    SetItem(string, string)

    Stores an item in the in-memory cache.

    Declaration
    public void SetItem(string key, string value)
    Parameters
    Type Name Description
    string key

    The key to store the value under

    string value

    The value to store

    Remarks

    Special handling for the "authToken" key to maintain fast access to the current authentication token.

    In this article
    Back to top Generated by DocFX