title: Representing and persisting Users (who login with username and password AND social logins) in a database (MySQL)
body: <p>I am using Play Framework (v2.2.x), SecureSocial (v2.1.3) and scala (v2.10) to create a login template for play apps. I want the login template to support both social logins (Twitter, Facebook, Github etc.) and UsernamePassword login. I am having a difficult time representing both kinds of Users (Social and Local) for persistence. </p>
  
  <p>I am using MySQL(v 5.6.x) as my database and squeryl (v0.9.6) as the ORM for persistence. </p>
  
  <p>I need some help in modeling both SocialUser and LocalUser (users authenticating using username and password) for persistence. </p>
  
  <p>I have looked at <a href="https://github.com/jaliss/securesocial/tree/master/samples/scala/demo" rel="nofollow noreferrer">https://github.com/jaliss/securesocial/tree/master/samples/scala/demo</a>. I have that demo running (with additional set up for mysql and squeryl. Also, extended that example to work with Facebook and Github). </p>
  
  <p>I have not written any code yet, but I was planning to model as follows: </p>
  
  <p>User Class:</p>
  
  <pre><code>+-------------------+---------------+------------+---------------+-------------+-------------+-----------+
  | provider_user_id  | providerType  |    email   |   avatarUrl   | passwordInfo| oauth1Info  | oauth2Info|
  +-------------------+---------------+------------+---------------+-------------+-------------+-----------+
  </code></pre>
  
  <p>AuthProviderForUser: </p>
  
  <pre><code>+-------------------+----------------------+--------------+
  | provider_user_id  | application_user_id  | providerType |
  +-------------------+----------------------+--------------+
  </code></pre>
  
  <p>Token class: </p>
  
  <pre><code>+------+--------+---------------+-----------------+-----------+------------+
  | uuid |  email |  creationTime |  expirationTime |  isSignUp |  isExpired |
  +------+--------+---------------+-----------------+-----------+------------+
  </code></pre>
  
  <p>In the UserService should I just grab the information from these models, prepare the identity instance and return/use it? </p>
  
  <p>OR</p>
  
  <p>Am I better off having one User class (SocialUser class) with Identity trait and persist that?  </p>
  
  <p>You can think of this as an extension to <a href="https://stackoverflow.com/a/16389116/2343569">https://stackoverflow.com/a/16389116/2343569</a>. Basically, from a design point of view, is it better to persist PlatformUser or break PlatformUser into the classes (like User and AuthProviderForUser) and then persist those?</p>
  
  <p>Which option is better? Any other suggestion?</p>