mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
fix(api): keep auth sync timestamps monotonic
Use PostgreSQL's clock for both the initial auth sync timestamp and later identity refreshes so host clock skew cannot move the marker backwards.
This commit is contained in:
1 parent
2bc69c2790
commit
266233a473
1 file changed
+4
-1
@@ -83,7 +83,10 @@ export class PostgresRepository implements ApiRepository {
|
|||||||
target: profiles.id,
|
target: profiles.id,
|
||||||
set: {
|
set: {
|
||||||
email: sql`coalesce(excluded.email, ${profiles.email})`,
|
email: sql`coalesce(excluded.email, ${profiles.email})`,
|
||||||
authSyncedAt: new Date(),
|
// Keep the write on the same clock as the column default. API and
|
||||||
|
// PostgreSQL hosts can differ slightly, which must not move this
|
||||||
|
// monotonic sync marker backwards.
|
||||||
|
authSyncedAt: sql`now()`,
|
||||||
},
|
},
|
||||||
}).returning();
|
}).returning();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user