useMongocampAccount
Wraps the authApi methods not already surfaced by @sfxcode/nuxt-mongocamp-server's own useMongocampAuth() (login, logout, isAuthenticated, isLoggedIn, userRoles, userGrants). Powers MongocampAccount.
const {
changingPassword, // Ref<boolean>
fetchProfile, // () => Promise<UserProfile>
changePassword, // (password: string) => Promise<boolean>
regenerateApiKey, // () => Promise<string>
updateDisplayName, // (name) => Promise<UserProfile> — server 3.1
} = useMongocampAccount()fetchProfile
Returns the full UserProfile (user, isAdmin, apiKey?, roles?, grants?) of the currently logged-in user via authApi.userProfile().
changePassword
const success = await changePassword('new-password')Follows the same convention as useMongocampFiles's uploadFile: owns its own loading flag (changingPassword), shows a success/error toast, and returns a boolean.
updateDisplayName (server 3.1)
PATCH /auth/profile { displayName } for the signed-in user (15 s timeout): the name is trimmed, an empty one removes it (null). Answers the updated profile and updates the stored session profile's displayName. Only the display name can be changed this way (another field is a 400); a server without the own-profile route answers 404 — the call rejects, the caller shows the reason.
regenerateApiKey
const newKey = await regenerateApiKey()Calls authApi.generateNewApiKey() and returns the raw key string. This is the only time the new key is retrievable — the server doesn't expose it again afterward, so the UI must display it prominently once (see MongocampAccount) rather than just toasting a generic "success" message.
No manual "refresh session" method
@sfxcode/nuxt-mongocamp-server's useMongocampAuth() already runs a background setInterval that calls authApi.refreshToken() automatically (gated by the module's refreshToken/tokenRefreshInterval options, both defaulted to true/5000 in this module's moduleDependencies) for as long as the user is logged in. A manual refresh method here would just duplicate that — there's intentionally no refreshSession() export.