I tried logging in through “uxmode: redirect”. And I’m trying to call the API through “ADAPTER_EVENTS.CONNECTED” value of reconnected. However, in this mode, the value of reconnected always comes to “true”, even though it is initial. Is there an appropriate section to put the login API through a different lifecycle?
(In the “uxmode: popup”, it returned “false” the first time.)
using @web3auth/core
useEffect(() => {
const subscribeAuthEvents = (web3auth: Web3AuthCore) => {
web3auth.on(ADAPTER_EVENTS.CONNECTED, async (data: IWeb3AuthData) => {
console.log('Yeah!, you are successfully logged in', data);
setUser(data);
setWalletProvider(web3auth.provider!);
if (!data.reconnected) {
// LOGIN API REQUEST area [if success. get Accesstoken]
}
});
async function init() {
try {
setIsLoading(true);
const web3AuthInstance = new Web3AuthCore({
chainConfig: CHAIN_CONFIG[CHAIN_ENV],
clientId,
web3AuthNetwork: CHAIN_ENV,
});
const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
clientId,
network: CHAIN_ENV,
uxMode: 'redirect',
},
});
web3AuthInstance.configureAdapter(openloginAdapter);
subscribeAuthEvents(web3AuthInstance);
setWeb3Auth(web3AuthInstance);
await web3AuthInstance.init();
} catch (error) {
console.error(error);
} finally {
setIsLoading(false);
}
}
init();
}, [setWalletProvider]);