mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 01:11:13 -05:00
feat: Complete type safety for Phase 1 & 2
This commit is contained in:
@@ -33,6 +33,15 @@ interface PasswordUpdateDialogProps {
|
||||
|
||||
type Step = 'password' | 'mfa' | 'success';
|
||||
|
||||
interface ErrorWithCode {
|
||||
code?: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
function isErrorWithCode(error: unknown): error is Error & ErrorWithCode {
|
||||
return error instanceof Error && ('code' in error || 'status' in error);
|
||||
}
|
||||
|
||||
export function PasswordUpdateDialog({ open, onOpenChange, onSuccess }: PasswordUpdateDialogProps) {
|
||||
const { theme } = useTheme();
|
||||
const [step, setStep] = useState<Step>('password');
|
||||
@@ -135,16 +144,20 @@ export function PasswordUpdateDialog({ open, onOpenChange, onSuccess }: Password
|
||||
await updatePasswordWithNonce(data.newPassword, generatedNonce);
|
||||
}
|
||||
} catch (error) {
|
||||
const errorDetails = isErrorWithCode(error) ? {
|
||||
errorCode: error.code,
|
||||
errorStatus: error.status
|
||||
} : {};
|
||||
|
||||
logger.error('Password change failed', {
|
||||
userId,
|
||||
action: 'password_change',
|
||||
error: getErrorMessage(error),
|
||||
errorCode: error instanceof Error && 'code' in error ? (error as any).code : undefined,
|
||||
errorStatus: error instanceof Error && 'status' in error ? (error as any).status : undefined
|
||||
...errorDetails
|
||||
});
|
||||
|
||||
const errorMessage = getErrorMessage(error);
|
||||
const errorStatus = error instanceof Error && 'status' in error ? (error as any).status : undefined;
|
||||
const errorStatus = isErrorWithCode(error) ? error.status : undefined;
|
||||
|
||||
if (errorMessage?.includes('rate limit') || errorStatus === 429) {
|
||||
handleError(
|
||||
|
||||
Reference in New Issue
Block a user