initial commit
[squeep-indie-auther] / src / db / postgres / sql / tokens-get-by-identifier.sql
1 --
2 SELECT
3 t.code_id,
4 p.profile,
5 t.created,
6 t.expires,
7 t.refresh_expires,
8 t.refreshed,
9 t.duration,
10 t.refresh_duration,
11 t.refresh_count,
12 t.is_revoked,
13 t.is_token,
14 t.client_id,
15 t.resource,
16 t.profile_data,
17 a.identifier,
18 ARRAY(
19 SELECT s.scope FROM token_scope ts INNER JOIN scope s USING (scope_id)
20 WHERE ts.code_id = t.code_id
21 ) AS scopes
22 FROM token t
23 INNER JOIN profile p USING (profile_id)
24 INNER JOIN authentication a USING (identifier_id)
25 WHERE a.identifier = $(identifier)
26 ORDER BY GREATEST(t.created, t.refreshed) DESC