Skip to content
Merged

fix #188

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/(auth)/verify-otp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ export default function VerifyOtpPage() {
setIsLoading(true);
setError('');
try {
const res = await verifyLoginOtp({ email: storedEmail, otp: otpCode }) as { user: { id: string; name: string; email: string; role: 'USER' | 'ADMIN' }; accessToken: string; refreshToken: string };
setAuth(res.user, res.accessToken, res.refreshToken);
const res = await verifyLoginOtp({ email: storedEmail, otp: otpCode }) as { user: { id: string; firstName: string; lastName: string; email: string; role: 'USER' | 'ADMIN' }; accessToken: string; refreshToken: string };
const fullName = [res.user.firstName, res.user.lastName].filter(Boolean).join(' ');
setAuth({ ...res.user, name: fullName }, res.accessToken, res.refreshToken);
setIsLoading(false);
router.push('/dashboard');
} catch (err: unknown) {
Expand Down
2 changes: 2 additions & 0 deletions components/profile/profile-edit-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export function ProfileEditForm() {
setAuth(
{
id: updated.id,
firstName: updated.firstName,
lastName: updated.lastName,
name: `${updated.firstName} ${updated.lastName}`,
email: updated.email,
role: 'USER',
Expand Down
2 changes: 2 additions & 0 deletions components/profile/profile-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export function ProfileOverview() {
setAuth(
{
id: data.id,
firstName: data.firstName,
lastName: data.lastName,
name: `${data.firstName} ${data.lastName}`,
email: data.email,
role: 'USER',
Expand Down
4 changes: 3 additions & 1 deletion hooks/use-auth-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export interface UserProfileStore {

interface User {
id: string;
name: string;
firstName: string;
lastName: string;
name: string; // derived from firstName + lastName
email: string;
role: "USER" | "ADMIN";
// Optionally add more fields if needed
Expand Down
Loading