Type Alias: UserInformation
@arolariu/website / types / UserInformation
Type Alias: UserInformation
UserInformation =
object
Defined in: types/index.ts:326
Consolidated user authentication and authorization information.
Remarks
Authentication Provider: Uses Clerk for user management and JWT generation.
Purpose: Provides a single source of truth for user-related data throughout the application, combining Clerk's user object with custom identifiers and tokens.
Properties:
user: Clerk user object with profile data (name, email, avatar). Null when unauthenticated.userIdentifier: Custom unique identifier for the user (typically Clerk user ID or email)userJwt: JSON Web Token for authorizing API requests to the backend
Null Handling: When user is null, the user is not authenticated.
However, userIdentifier and userJwt may still contain values from previous sessions
(e.g., expired tokens). Always check user for authentication status.
JWT Usage: The userJwt is passed in the Authorization: Bearer <token> header
for all authenticated API requests to api.arolariu.ro.
Security: JWT tokens are sensitive. Never log or expose them in client-side code. Tokens are automatically refreshed by Clerk and should be fetched fresh for each request.
Usage Context:
- User profile components
- Protected route guards
- API request authentication
- Personalized content rendering
Example
// Authenticated user
const userInfo: UserInformation = {
user: {
id: "user_abc123",
emailAddresses: [{ emailAddress: "user@example.com" }],
firstName: "John",
lastName: "Doe"
},
userIdentifier: "user_abc123",
userJwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
};
// Unauthenticated user
const anonymousInfo: UserInformation = {
user: null,
userIdentifier: "",
userJwt: ""
};
// Checking authentication
if (userInfo.user) {
// User is authenticated, proceed with protected action
await fetchUserInvoices(userInfo.userJwt);
}
See
User - Clerk user type
Properties
user
user:
User|null
Defined in: types/index.ts:327
userIdentifier
userIdentifier:
string
Defined in: types/index.ts:328
userJwt
userJwt:
string
Defined in: types/index.ts:329