Connection Exceptions
Handling Connection Errors and Duplication in Account Management
π¨βπΌ Because of the page, users
can connect multiple third party accounts to their profile. But we don't allow
a third party account to be connected to more than one profile. If we did, how
would we know which profile the user is trying to login with?
So we need to make sure users can't connect a third party account to their
account if it's already connected to another user's account (even if its their
own π
).
So in this step, you need to search the database for an existing connection and
you'll get the
userId from the request. If there's a connection and there's a
userId, then they're trying to connect an account that has already been
connected and we should show an error in that case.π§ββοΈ With the way I put the mocks together, you'll get a different GitHub user if
you change the
code in handleMockAction
in . And our seed
script initializes a github user for Kody as well. So the code
MOCK_GITHUB_CODE_KODY will connect you to the profile that is already
connected to Kody. So to test this, try the following:- Sign in as Kody (username:
kody, password:kodylovesyou) - Go to
- Make sure
codeis set toMOCK_GITHUB_CODE_KODYin - Click "Connect with GitHub"
You should get an error indicating this account is already connected to you.
This should send you to
/login, but because you're already logged in, you'll
ultimately get sent to /. We still need to implement connecting the account,
so we're good here.Now if you want to test the other case...
- change
codein back toMOCK_GITHUB_CODE_KODY - Logout of kody on
- Go to
- Choose any user, copy their username
- Go to
- Enter the copied username in the username and password fields
- Go to
- Click "Connect with GitHub"
You should get an error indicating that the GitHub account is already connected
to another account.




