Skip to content

Commit

Permalink
Add: createTransaction saga force re-auth check
Browse files Browse the repository at this point in the history
  • Loading branch information
rdig committed Apr 4, 2024
1 parent 03e2c13 commit 08e0ada
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ export const authenticateWallet = async (): Promise<void> => {

const signature = await signer.signMessage(message);

await authProxyRequest('auth', {
return authProxyRequest('auth', {
method: 'POST',
body: JSON.stringify({ message, signature }),
});
}

return authCheck;
};
3 changes: 3 additions & 0 deletions src/components/shared/Fields/Form/ActionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { type FieldValues, type UseFormReturn } from 'react-hook-form';

import { authenticateWallet } from '~auth';
import useAsyncFunction from '~hooks/useAsyncFunction.ts';
import { type ActionTypes, type ActionTypeString } from '~redux/index.ts';
import { type ActionTransformFnType, getFormAction } from '~utils/actions.ts';
Expand Down Expand Up @@ -66,6 +67,8 @@ const ActionForm = <V extends Record<string, any>>({
});
const handleSubmit: CustomSubmitHandler<V> = async (values, formHelpers) => {
try {
// Force re-auth check to account for loss of auth/connection after the session has been started
await authenticateWallet();
const res = await asyncFunction(values);
onSuccess?.(values, formHelpers, res);
} catch (e) {
Expand Down

0 comments on commit 08e0ada

Please sign in to comment.