Please help me understand how Gun manages users in a sometimes-disconnected P2P network.
Let's say there are two Gun instances, I1 and I2, that are configured to be peers, and also let's assume user "doe" did not exist beforehand on either I1 or I2. Suppose user "doe" is created on both instances while I1 and I2 are not connected. Both attempts should succeed. For the sake of argument, let's call the "doe" user on I1 doe1, and that on I2, doe2.
Now, what happens when I1 and I2 are connected? Are doe1 and doe2 considered to be the same user or not? Will it depend on the passwords given at the time of user registration?
My understanding is that they are, as long as the passwords given at user registration are the same. This is reasonable. But my big question is, what if they were given different passwords?
I would think in that case, doe1 and doe2 will be considered different users... but then what? How will I1 and I2 treat this situation? Will I1 simply reject doe2 and vice versa? Or is this left to the implementation?
Your advice will be much appreciated. Thank you.
Yasuro
@Yasuro great Q:
GUN usernames (alias) is NOT unique.
The cryptographic public keys are universally unique.
You are correct "Doe" can be created offline.
Without going online, or syncing somehow, the user should click "login" and it will fail (you should error that they are offline). If they click "create" then a new public key will be generated, both accounts will share the same "Doe" username (just like how Discord lets 2 people have the same username).
No, once connected, they will stay as different accounts.
In real life, these will be different users with different passwords, and so they will correctly login to there account (GUN runs cryptography on each, and only logs into the one that the password succeeds with).
However, if the user accidentally did click "create" twice (or more), using the same password each time, then yes, there account will be fragmented with disconnected data - it should be easy to write code that synchronizes the accounts, given GUN does sync. Hopefully someone will make this as a little module for others to use - will you??? :)