title: Loopback 2 user types with the same userId
body: <p>I'm trying to get Loopback ready for my enterprise credentials using Passport, but I ran across something that maybe I'm doing wrong.</p>
  
  <p>First off I have 2 different types of users: <code>participant</code> and <code>judge</code>.  Both of these models have a base of <code>User</code>.  I'm also using the memory database for now (eventually going to Mongo).</p>
  
  <p>When I use the Passport example as a base, I have 3 other models defined:</p>
  
  <ul>
  <li>AccessToken</li>
  <li>userCredential</li>
  <li>userIdentity</li>
  </ul>
  
  <p>All seems well when I'm able to login with <code>/participants/login</code> and get an accessToken in return.  I can also access <code>/participants/1</code> just fine (the ID of the logged in user).</p>
  
  <p>Now with the same token I'm able to access <code>/judges/1</code> as well!!  This seems like a bit of a risk.  Now I know with mongo I probably won't get the same ID but that's besides the point (unless that's how it's supposed to work).</p>
  
  <p>I did try and mess with the relations a bit, but found that if I make anything other than <code>foreignKey: 'userId'</code> in my relations, it'll fail to login.</p>
  
  <p>Here's a snippet of the database:</p>
  
  <pre><code>"participant": {
    "1": "{\"createdDate\":\"2016-05-16T18:37:38.956Z\",\"name\":\"Participant Weed\",\"pin\":\"N0148094\",\"awaitingTeam\":true,\"videoSigned\":false,\"password\":\"$2a$10$NgIjGMEPUvmworA/C0vTiu2lA52SQqR6QXkOwh8IfJWVJBF8izDAu\",\"email\":\"t@lm.com\",\"id\":1}",
    "2": "{\"createdDate\":\"2016-05-16T18:37:38.956Z\",\"name\":\"Other Participant Weed\",\"pin\":\"N0148094\",\"awaitingTeam\":true,\"videoSigned\":false,\"password\":\"$2a$10$joljfw98Lf.3qdnIwf55nOEotAE3Zrcr97Fe5XKPE7j1PFy5O2h5.\",\"email\":\"t2@lm.com\",\"id\":2}"
  },
  "judge": {
    "1": "{\"createdDate\":\"2016-05-16T18:37:38.956Z\",\"name\":\"Judge Weed\",\"pin\":\"N0148094\",\"password\":\"$2a$10$ZiCmsGos3t7UYOpSK7s3BeAIIJ9lL0XjplOghOCXp1WTfh2MOr0vS\",\"email\":\"j@lm.com\",\"id\":1}"
  },
  </code></pre>
  
  <p>Here what my relations look like for <code>participant</code>:</p>
  
  <pre><code>"relations": {
    "identities": {
      "type": "hasMany",
      "model": "userIdentity",
      "foreignKey": "userId"
    },
    "credentials": {
      "type": "hasMany",
      "model": "userCredential",
      "foreignKey": "userId"
    },
    "accessTokens": {
      "type": "hasMany",
      "model": "AccessToken",
      "foreignKey": "userId"
    }
  },
  </code></pre>
  
  <p>Notice how I have to use <code>"userId"</code>.  These are exactly the same for <code>judge</code> as well.  I tried using <code>"participantId"</code> but kept getting <code>401</code> errors whenever I tried to log in with that.</p>