mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: sync the isVerified state of authed user
This commit is contained in:
@@ -78,7 +78,7 @@ export const useAuthResetPassword = (props) => {
|
||||
*/
|
||||
export const useAuthMetadata = (props) => {
|
||||
return useRequestQuery(
|
||||
[t.AUTH_METADATA_PAGE,],
|
||||
[t.AUTH_METADATA_PAGE],
|
||||
{
|
||||
method: 'get',
|
||||
url: `auth/meta`,
|
||||
@@ -88,12 +88,11 @@ export const useAuthMetadata = (props) => {
|
||||
defaultData: {},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
export const useAuthSignUpVerifyResendMail = (props) => {
|
||||
const apiRequest = useApiRequest();
|
||||
@@ -104,16 +103,20 @@ export const useAuthSignUpVerifyResendMail = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
interface AuthSignUpVerifyValues {
|
||||
token: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
export const useAuthSignUpVerify = (props) => {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(token: string, email: string) => apiRequest.post('auth/register/verify'),
|
||||
(values: AuthSignUpVerifyValues) =>
|
||||
apiRequest.post('auth/register/verify', values),
|
||||
props,
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useQueryTenant, useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useSetFeatureDashboardMeta } from '../state/feature';
|
||||
import t from './types';
|
||||
import { useSetAuthEmailConfirmed } from '../state';
|
||||
|
||||
// Common invalidate queries.
|
||||
const commonInvalidateQueries = (queryClient) => {
|
||||
@@ -130,6 +131,8 @@ export function useUser(id, props) {
|
||||
}
|
||||
|
||||
export function useAuthenticatedAccount(props) {
|
||||
const setEmailConfirmed = useSetAuthEmailConfirmed();
|
||||
|
||||
return useRequestQuery(
|
||||
['AuthenticatedAccount'],
|
||||
{
|
||||
@@ -139,6 +142,9 @@ export function useAuthenticatedAccount(props) {
|
||||
{
|
||||
select: (response) => response.data.data,
|
||||
defaultData: {},
|
||||
onSuccess: (data) => {
|
||||
setEmailConfirmed(data.is_verified);
|
||||
},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
@@ -166,4 +172,3 @@ export const useDashboardMeta = (props) => {
|
||||
}, [state.isSuccess, state.data, setFeatureDashboardMeta]);
|
||||
return state;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user