Skip to main content

GdAuthStore

The GdAuthStore manages authentication state, including the current user and login status.

Import

import { GdAuthStore } from '@geodome/gdk/core';

Features

  • Tracks the authenticated user.
  • Provides a computed property to check login status.
  • Supports methods for setting and clearing the user state.

Methods

setUser(user)

Sets the current user in the authentication store.

Parameters
  • user: The user object to set as the current user.

clearUser()

Clears the user state, effectively logging the user out.


State Access

Accessing the Current User

You can access the current authenticated user through the user state in the GdAuthStore.

user

  • Represents the current user stored in the authentication state.
  • Returns null if no user is authenticated.
const authStore = inject(GdAuthStore);
const currentUser = authStore.user();

Computed Properties

loggedIn

Indicates whether a user is authenticated.

  • Returns true if a user is authenticated.
  • Returns false if no user is authenticated.