bump package version to 1.1.0
[squeep-indie-auther] / src / db / sqlite / sql / redeem-code.sql
1 --
2 INSERT INTO token (
3 code_id,
4 created,
5 is_token,
6 client_id,
7 profile_id,
8 expires,
9 duration,
10 refresh_expires,
11 refresh_duration
12 )
13 SELECT
14 :codeId,
15 :created,
16 :isToken,
17 :clientId,
18 p.profile_id,
19 CASE WHEN :lifespanSeconds IS NULL THEN NULL ELSE :created + :lifespanSeconds END,
20 :lifespanSeconds,
21 CASE WHEN :refreshLifespanSeconds IS NULL THEN NULL ELSE :created + :refreshLifespanSeconds END,
22 :refreshLifespanSeconds
23 FROM profile p INNER JOIN authentication a USING (identifier_id)
24 WHERE p.profile = :profile AND a.identifier = :identifier
25 ON CONFLICT (code_id) DO UPDATE
26 SET is_revoked = true
27 RETURNING is_revoked