Connection Exceptions

πŸ‘¨β€πŸ’Ό 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:
  1. Sign in as Kody (username: kody, password: kodylovesyou)
  2. Go to
  3. Make sure code is set to MOCK_GITHUB_CODE_KODY in
  4. Click "Connect with GitHub"
You should get an error indicating this account is already connected to you.
Then, change code in to MOCK_GITHUB_CODE_KODY2, and try again.
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...
  1. change code in back to MOCK_GITHUB_CODE_KODY
  2. Logout of kody on
  3. Go to
  4. Choose any user, copy their username
  5. Go to
  6. Enter the copied username in the username and password fields
  7. Go to
  8. Click "Connect with GitHub"
You should get an error indicating that the GitHub account is already connected to another account.

Access Denied

You must login or register for the workshop to view and run the tests.

Check out this video to see how the test tab works.