fix(settings): app crashing when restarting

This commit is contained in:
Nicolas Meienberger 2023-10-12 20:43:37 +02:00
parent 986784d81c
commit c70a0845a8
3 changed files with 7 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import { action } from '@/lib/safe-action';
import { getUserFromCookie } from '@/server/common/session.helpers';
import { AuthServiceClass } from '@/server/services/auth/auth.service';
import { db } from '@/server/db';
import { revalidatePath } from 'next/cache';
import { handleActionError } from '../utils/handle-action-error';
const input = z.object({ password: z.string() });
@ -23,6 +24,8 @@ export const disableTotpAction = action(input, async ({ password }) => {
const authService = new AuthServiceClass(db);
await authService.disableTotp({ userId: user.id, password });
revalidatePath('/settings');
return { success: true };
} catch (e) {
return handleActionError(e);

View file

@ -5,6 +5,7 @@ import { action } from '@/lib/safe-action';
import { getUserFromCookie } from '@/server/common/session.helpers';
import { AuthServiceClass } from '@/server/services/auth/auth.service';
import { db } from '@/server/db';
import { revalidatePath } from 'next/cache';
import { handleActionError } from '../utils/handle-action-error';
const input = z.object({ totpCode: z.string() });
@ -23,6 +24,8 @@ export const setupTotpAction = action(input, async ({ totpCode }) => {
const authService = new AuthServiceClass(db);
await authService.setupTotp({ userId: user.id, totpCode });
revalidatePath('/settings');
return { success: true };
} catch (e) {
return handleActionError(e);

View file

@ -20,7 +20,7 @@ export const StatusProvider: React.FC<IProps> = ({ children }) => {
const getStatusMutation = useAction(getStatusAction, {
onSuccess: (data) => {
if (data.success) {
if (data?.success) {
setStatus(data.status);
}
},