I got this year but after clean up the local storage and index DP and then reload the page it work just fine
This happens straight after the user login with the Internet identity when we call the registration function from the back canister. However doesn’t in any other scenarios on the cases we called the back and just fine
my code
```ts
const handleRegister = async () => {
if (!formValues.username || !formValues.bio) {
enqueueSnackbar(“Please fill all required fields”, { variant: “error” });
return;
}
// Get identity and host from auth client
const { AuthClient } = await import(“@dfinity/auth-client”);
const client = await AuthClient.create({
idleOptions: {
disableIdle: true,
disableDefaultIdleCallback: true,
idleTimeout: 30 \* 24 \* 60 \* 60 \* 1000,
},
});
const identity = client.getIdentity();
const host =
import.meta.env.VITE_DFX_NETWORK !== “ic”
? import.meta.env.VITE_IC_HOST
: “https://ic0.app”;
const agent = new HttpAgent({ identity, host });
// Fetch root key for local development
if (import.meta.env.VITE_DFX_NETWORK !== “ic”) {
await agent.fetchRootKey().catch(() => {});
}
const smartBackendActor = Actor.createActor<_SERVICE>(idlFactory, {
agent,
canisterId,
});
const backendActor = new Proxy({} as ActorSubclass<_SERVICE>, {
get(target, prop) {
return smartBackendActor[prop as keyof ActorSubclass<_SERVICE>];
},
});
setLoading(true);
try {
let photoBytes: Uint8Array | null = null;
if (photo) {
photoBytes = await fileToUint8Array(photo);
}
const input: RegisterUser = {
name: formValues.username ? [formValues.username] : ,
description: formValues.bio ? [formValues.bio] : ,
photo: photoBytes ? [Array.from(photoBytes)] : [],
email: formValues.email ? [formValues.email] : ,
};
const result = await backendActor.register(
localStorage.getItem(“affiliateId”) || “”,
input,
);
if (result?.Ok) {
enqueueSnackbar(`Welcome ${result.Ok.name}, to Odoc`, {
variant: “success”,
});
window.location.href = window.location.origin;
} else if (result?.Err) {
enqueueSnackbar(result.Err, { variant: “error” });
}
} catch (error) {
console.log(“Error registering user:”, { error });
alert(“Something went wrong please try again in a second”);
// await cleanUp();
} finally {
setLoading(false);
}
};
```
RegistrationForm.tsx:114 Registration error: AgentCallError: Error while making call: Server returned an error: Code: 400 (Bad Request) Body: Invalid signature: Invalid basic signature: EcdsaP256 signature could not be verified: public key 04dfc64d0af35b69e40952b6bcc1ebcb9f93489242d819ada8794c5a907eb5f8fd0b12a1b2a5fdab5d822e92cfaeab7040d69631eaea8b174555861951db496fdc, signature c19ae71b420b9ac076d33dca5fb8ebc2530fc5010153a62770e0c3be4fe9678698515f24e39a6f4b72e50f0d291ea03a513a327a72184044b85e62a450688b66, error: verification failed at async handleRegister (RegistrationForm.tsx:97:22)
| handleRegister | @ | RegistrationForm.tsx:114 | |
|---|---|---|---|
my code : oDoc/src/frontend/components/MainComponents/RegistrationForm.tsx at dev2 · aliscie2/oDoc · GitHub