frontend/src/hooks/useAuth.js
// renew access token independen if existing
renew access token independen if existing
renew access token independen if existing
async function renewAccessTokenAsync() {
        const response = await fetch(`/api/auth/refreshTokenSilent`, { method: 'POST', credentials: 'include' });
        if (response.status === 200) {
            const data = await response.json();
            setState(state => ({
                ...state,
                tokenType: data.tokenType,
                accessToken: data.accessToken
            }));
            return `${data.tokenType} ${data.accessToken}`
        } else {
            setState(state => ({
                ...state,
                tokenType: null,
                accessToken: null
            }));
            return null;
        }
    }
async function renewAccessTokenAsync ( ) { const response = await fetch ( ` ` , { method : 'POST' , credentials : 'include' } ) ; if ( response . status === 200 ) { const data = await response . json ( ) ; setState ( state => ( { ... state , tokenType : data . tokenType , accessToken : data . accessToken } ) ) ; return ` ${ data . tokenType } ${ data . accessToken } ` } else { setState ( state => ( { ... state , tokenType : null , accessToken : null } ) ) ; return null ; } }
renew access token independen if existing
renew access token independen if existing