aboutsummaryrefslogtreecommitdiff
path: root/crates/secd/store/pg/sql/write_oauth_validation.sql
blob: 11f25788846b72348fa1a322d70e52c628ff6711 (plain)
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
43
44
45
insert into secd.oauth_validation (
       oauth_validation_public_id
       , oauth_provider_id
       , access_token
       , raw_response
       , created_at
       , validated_at
) values (
       $1
       , (
         select oauth_provider_id
         from secd.oauth_provider
         where name = $2
         and flow = $3
       )
       , $4
       , $5
       , $6
       , $7
) on conflict (oauth_validation_public_id) do update
  set access_token = excluded.access_token
      , validated_at = excluded.validated_at
      , raw_response = excluded.raw_response;
--
insert into secd.identity_oauth_validation (
       identity_id
       , oauth_validation_id
       , revoked_at
       , deleted_at
) values (
       (
       select identity_id
       from secd.identity
       where identity_public_id = $1
       )
       , (
         select oauth_validation_id
         from secd.oauth_validation
         where oauth_validation_public_id = $2
       )
       , $3
       , $4
) on conflict (identity_id, oauth_validation_id) do update
  set revoked_at = excluded.revoked_at
      , deleted_at = excluded.deleted_at;