690401:0842 fix setting pagre
This commit is contained in:
@@ -96,13 +96,16 @@ export default function SettingsPage() {
|
||||
<div>
|
||||
<p className="font-medium">Current User</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{user?.fullName || user?.username || 'Unknown'} ({user?.role})
|
||||
{user?.firstName && user?.lastName
|
||||
? `${user.firstName} ${user.lastName}`
|
||||
: user?.username || 'Unknown'}{' '}
|
||||
({user?.role})
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">Organization</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{user?.primaryOrganization?.organizationName || 'Not assigned'}
|
||||
{user?.primaryOrganizationName || 'Not assigned'}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -32,11 +32,12 @@ export function AuthSync() {
|
||||
setAuth(
|
||||
{
|
||||
id: user.id || user.user_id || '',
|
||||
username: user.username || '',
|
||||
email: user.email || '',
|
||||
firstName: user.firstName || '',
|
||||
lastName: user.lastName || '',
|
||||
role: user.role || 'User',
|
||||
publicId: session.user.publicId, // ✅ ADR-019
|
||||
username: user.username || session.user.username || '',
|
||||
email: user.email || session.user.email || '',
|
||||
firstName: user.firstName || session.user.firstName || '',
|
||||
lastName: user.lastName || session.user.lastName || '',
|
||||
role: user.role || session.user.role || 'User',
|
||||
permissions: user.permissions,
|
||||
},
|
||||
(session as { accessToken?: string }).accessToken || ''
|
||||
|
||||
@@ -33,6 +33,7 @@ interface TokenPayload {
|
||||
|
||||
interface LoginPayload extends TokenPayload {
|
||||
user: {
|
||||
publicId: string; // ✅ Added (ADR-019)
|
||||
user_id: number;
|
||||
username: string;
|
||||
email?: string;
|
||||
@@ -162,9 +163,12 @@ export const {
|
||||
|
||||
return {
|
||||
id: backendData.user.user_id.toString(),
|
||||
publicId: backendData.user.publicId, // ✅ Added (ADR-019 Waived for session)
|
||||
name: `${backendData.user.firstName ?? ''} ${backendData.user.lastName ?? ''}`.trim(),
|
||||
email: backendData.user.email,
|
||||
username: backendData.user.username,
|
||||
firstName: backendData.user.firstName, // ✅ Added
|
||||
lastName: backendData.user.lastName, // ✅ Added
|
||||
role: backendData.user.role || 'User',
|
||||
organizationId: backendData.user.primaryOrganizationId,
|
||||
accessToken: backendData.access_token,
|
||||
@@ -186,7 +190,10 @@ export const {
|
||||
return {
|
||||
...token,
|
||||
id: user.id,
|
||||
publicId: user.publicId, // ✅ Save publicId
|
||||
username: user.username, // ✅ Save username
|
||||
firstName: user.firstName, // ✅ Save firstName
|
||||
lastName: user.lastName, // ✅ Save lastName
|
||||
role: user.role,
|
||||
organizationId: user.organizationId,
|
||||
accessToken: user.accessToken,
|
||||
@@ -211,7 +218,10 @@ export const {
|
||||
async session({ session, token }) {
|
||||
if (token && session.user) {
|
||||
session.user.id = token.id as string;
|
||||
session.user.publicId = token.publicId as string; // ✅ Restore publicId
|
||||
session.user.username = token.username as string; // ✅ Restore username
|
||||
session.user.firstName = token.firstName as string; // ✅ Restore firstName
|
||||
session.user.lastName = token.lastName as string; // ✅ Restore lastName
|
||||
session.user.role = token.role as string;
|
||||
session.user.organizationId = token.organizationId as number;
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@ import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
id: string; // Internal stringified INT (for stability)
|
||||
publicId?: string; // ADR-019: Public UUIDv7
|
||||
username: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
role: string | 'User' | 'Admin' | 'Viewer';
|
||||
permissions?: string[];
|
||||
primaryOrganizationName?: string;
|
||||
}
|
||||
|
||||
interface AuthState {
|
||||
|
||||
Vendored
+6
@@ -5,7 +5,10 @@ declare module 'next-auth' {
|
||||
interface Session {
|
||||
user: {
|
||||
id: string;
|
||||
publicId: string; // ✅ Added (ADR-019 Waived for session)
|
||||
username: string; // ✅ Added
|
||||
firstName: string; // ✅ Added
|
||||
lastName: string; // ✅ Added
|
||||
role: string;
|
||||
organizationId?: number;
|
||||
} & DefaultSession['user'];
|
||||
@@ -16,7 +19,10 @@ declare module 'next-auth' {
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
publicId: string; // ✅ Added
|
||||
username: string; // ✅ Added
|
||||
firstName: string; // ✅ Added
|
||||
lastName: string; // ✅ Added
|
||||
role: string;
|
||||
organizationId?: number;
|
||||
accessToken?: string;
|
||||
|
||||
Reference in New Issue
Block a user