I am trying to set a uniqueId created after a user signs in from their Principal.
However, every time I login and logout a new Principal is issues resulting in multiple account creations.
const stored = localStorage.getItem("ic-identity");
if (stored) {
const identity = Ed25519KeyIdentity.fromJSON(stored);
const res = await run.counter.addAccount(identity.getPrincipal()).catch(err => {
})
console.log(res)
In Motoko:
public type UserData = {
id: Principal;
};
This all saves correctly other than that the Principal changes each time I login and out.
What is the correct way to generate a unique ID after signin?