File size: 1,037 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Base from './base.js';
import SamlAuthProvider from './saml-auth-provider.ee.js';
import User from './user.js';

class Identity extends Base {
  static tableName = 'identities';

  static jsonSchema = {
    type: 'object',
    required: ['providerId', 'remoteId', 'userId', 'providerType'],

    properties: {
      id: { type: 'string', format: 'uuid' },
      userId: { type: 'string', format: 'uuid' },
      remoteId: { type: 'string', minLength: 1 },
      providerId: { type: 'string', format: 'uuid' },
      providerType: { type: 'string', enum: ['saml'] },
    },
  };

  static relationMappings = () => ({
    user: {
      relation: Base.BelongsToOneRelation,
      modelClass: User,
      join: {
        from: 'users.id',
        to: 'identities.user_id',
      },
    },
    samlAuthProvider: {
      relation: Base.BelongsToOneRelation,
      modelClass: SamlAuthProvider,
      join: {
        from: 'saml_auth_providers.id',
        to: 'identities.provider_id',
      },
    },
  });
}

export default Identity;