Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / db/migrations/0059_touch_last_login.sql |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | db/migrations/0059_touch_last_login.sql |
| Original SHA-256 | fef2eb31de60d4c25fa7f0053e6e20892908af5daf446c057617937b57978da9 |
| Git blob SHA | d3a9c18331865a96156d2a1d2046bbdcf136c0f5 |
| Reading-copy SHA-256 | fef2eb31de60d4c25fa7f0053e6e20892908af5daf446c057617937b57978da9 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / db/migrations/0059_touch_last_login.sql | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / db/migrations/0059_touch_last_login.sql | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓28 lines · 1.4 KB
-- +goose Up
-- Records the last sign in, which nothing has ever done.
--
-- users.last_login_at and its generated query have existed since the foundation migration and no code
-- path called them, so the column was NULL for every account that had ever signed in. The People screen
-- added in phase 19 showed "never signed in" beside the owner who was reading it.
--
-- The first attempt at a fix was a plain UPDATE from the auth service, and it silently did nothing.
-- Login happens BEFORE any tenant context exists, so app.current_org_id is unset and the row level
-- policy on users matches zero rows. Every other privileged auth write goes through a SECURITY DEFINER
-- function for exactly this reason; the stamp needs the same treatment rather than an exception.
--
-- Scoped as tightly as the job allows: it writes one column on one row identified by primary key, and it
-- can neither read nor return anything.
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION auth_touch_last_login(p_user_id uuid) RETURNS void AS $$
BEGIN
UPDATE users SET last_login_at = now(), updated_at = now() WHERE id = p_user_id;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, pg_temp;
-- +goose StatementEnd
REVOKE ALL ON FUNCTION auth_touch_last_login(uuid) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION auth_touch_last_login(uuid) TO missionmatch_app;
-- +goose Down
DROP FUNCTION IF EXISTS auth_touch_last_login(uuid);