storeUser
Overview
The user store, handling user login, logout, and current user fetching.
Signature
storeUser(pinia, hot)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| pinia | Pinia | no | Pinia instance to retrieve the store |
| hot | StoreGeneric | no | dev only hot module replacement |
Returns
Store
Examples
js
import { storeUser } from "@vueda";
const user = storeUser();
user.loggedIn; // reactive boolean for login state, true if logged-in
user.loggedInUser; // reactive object for user details
user.initialized; // reactive boolean for initialization state, true if initialized
user.loading; // reactive boolean for loading state, true if loading
user.error; // reactive object for error details
user.errored; // reactive boolean for error state, true if errored
user.initializingPromise; // promise for initialization
user.init(); // fetch the current user, with initialization wrapping
user.login({username: "username", password: "password"}); // login
user.forgotPassword({email: "password"}); /
user.resetPassword({password: "password", password_confirm: "password_confirm"});
user.checkResetLinkIsValid(); // login
user.logout(); // logout
user.fetchCurrentUser(); // fetch the current userProperties
$id
Id of the store. Used by map helpers.
Type: "user"
Source: node_modules/.pnpm/pinia@3.0.4_typescript@5.9.3_vue@3.5.27_typescript@5.9.3_/node_modules/pinia/dist/pinia.d.ts:654
Source
client/lib/stores/storeUser.js:117