const user = await baas.auth.me();
if (user) {
console.log("Welcome back:", user.displayName, user.email);
}Update the profile fields (displayName, avatar, metadata) of the logged-in user. Note: The user email cannot be updated directly via this method due to multi-tenant database namespace isolation.
const updatedUser = await baas.auth.update({
displayName: "Alex New Name",
avatar: "https://example.com/avatar.png",
metadata: { age: 29 },
});
console.log("Updated profile:", updatedUser.displayName);Update the user's password. Doing so invalidates the current session on the backend and clears all local tokens globally (requiring a new login):
// This will clear local storage credentials and force a re-login
await baas.auth.updatePassword("NewSecurePassword123!");await baas.auth.logout();When retrieving the active profile context, the SDK resolves to a KroxtUser directly (or returns null if unauthenticated):
import type { KroxtUser } from "@kroxt/baas-sdk";
const user: KroxtUser | null = await baas.auth.me();
if (user) {
console.log("Active User Status:", user.status); // "active" | "disabled"
console.log("Active User Name:", user.displayName);
}