Skip to content

Commit 5dbe024

Browse files
committed
Merge branch 'develop' of github.com:UserOfficeProject/user-office-core into SWAP-5022-uo-co-proposer-email-lookup-fails-when-input-cont
2 parents 4b276dd + 55de9ea commit 5dbe024

126 files changed

Lines changed: 2779 additions & 1700 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rebase-prs-with-develop.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Update PRs with develop
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
sync-prs:
10+
# Disabled until we can push with a PAT that has workflow scope; otherwise CI stays in "Waiting".
11+
if: ${{ false }}
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Configure git user
21+
run: |
22+
git config --global user.name "github-actions[bot]"
23+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
24+
25+
- name: Merge develop into all open non-Dependabot PRs
26+
# TODO: Re-enable once we replace the default GITHUB_TOKEN with a PAT that has repo+workflow scopes
27+
# so that downstream PR checks trigger automatically after the bot pushes merge commits.
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
# Get all open PRs targeting develop, excluding Dependabot
32+
prs=$(gh pr list --state open --base develop --limit 100 --json number,author --jq '.[] | select(.author.is_bot != true) | .number')
33+
34+
for pr in $prs; do
35+
echo "Processing PR #$pr"
36+
gh pr checkout $pr
37+
git fetch origin develop
38+
39+
# Attempt merge
40+
if git merge --no-edit origin/develop; then
41+
echo "PR #$pr merged successfully. Pushing changes..."
42+
git push
43+
else
44+
echo "Conflict in PR #$pr. Merge aborted."
45+
git merge --abort
46+
# Optional: Notify author
47+
gh pr comment $pr --body "⚠️ Automatic merge of \`develop\` into this PR failed due to conflicts. Please resolve the conflicts and update your branch."
48+
fi
49+
done

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ apps/backend/node_modules
66
apps/frontend/src/generated
77
apps/backend/generated
88
.DS_Store
9+
documentation/.venv
10+
documentation/site/
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
DO
3+
$$
4+
DECLARE
5+
duplicate_count INTEGER;
6+
duplicate_details TEXT;
7+
BEGIN
8+
IF register_patch('AddUniqueConstraintToOidcSub.sql', 'yoganandanpandiyan', 'Unique constraint', '2025-10-13') THEN
9+
BEGIN
10+
-- Clean up empty string values in oidc_sub column by setting them to NULL
11+
-- This prevents empty strings from conflicting with the unique constraint
12+
UPDATE users
13+
SET oidc_sub = NULL
14+
WHERE oidc_sub = '';
15+
16+
-- Check for duplicate oidc_sub values and throw error if any are found
17+
SELECT COUNT(*)
18+
INTO duplicate_count
19+
FROM (
20+
SELECT oidc_sub
21+
FROM users
22+
WHERE oidc_sub IS NOT NULL
23+
GROUP BY oidc_sub
24+
HAVING COUNT(*) > 1
25+
) duplicates;
26+
27+
IF duplicate_count > 0 THEN
28+
WITH duplicate_groups AS (
29+
SELECT
30+
oidc_sub,
31+
STRING_AGG(user_id::TEXT, ', ' ORDER BY user_id) AS user_ids
32+
FROM users
33+
WHERE oidc_sub IS NOT NULL
34+
AND oidc_sub IN (
35+
SELECT oidc_sub
36+
FROM users
37+
WHERE oidc_sub IS NOT NULL
38+
GROUP BY oidc_sub
39+
HAVING COUNT(*) > 1
40+
)
41+
GROUP BY oidc_sub
42+
)
43+
SELECT STRING_AGG(
44+
FORMAT('oidc_sub: "%s" (user_ids: %s)', oidc_sub, user_ids),
45+
E'\n'
46+
)
47+
INTO duplicate_details
48+
FROM duplicate_groups;
49+
50+
RAISE EXCEPTION 'Cannot add unique constraint to oidc_sub column. Found % duplicate oidc_sub value(s) that must be manually resolved:
51+
%
52+
53+
Please manually fix these duplicate values before running this migration again.
54+
OIDC subject identifiers should be unique as they come from identity providers.',
55+
duplicate_count, duplicate_details;
56+
END IF;
57+
58+
-- Add unique constraint to prevent duplicate oidc_sub values in the future
59+
ALTER TABLE users
60+
ADD CONSTRAINT unique_oidc_sub UNIQUE (oidc_sub);
61+
END;
62+
END IF;
63+
END;
64+
$$
65+
LANGUAGE plpgsql;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DO
2+
$$
3+
BEGIN
4+
IF register_patch('DropUsersUsernameKey.sql', 'jekabskarklins', 'Deprecate username constraint. This fix is needed for the broken integration that is underway', '2025-12-11') THEN
5+
BEGIN
6+
ALTER TABLE IF EXISTS public.users
7+
DROP CONSTRAINT users_username_key;
8+
END;
9+
END IF;
10+
END;
11+
$$
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
DO
2+
$DO$
3+
DECLARE
4+
invite_id_var1 int;
5+
invite_id_var2 int;
6+
invite_id_var3 int;
7+
invite_id_var4 int;
8+
BEGIN
9+
10+
INSERT INTO invites (code, email, created_by, created_at, claimed_by, claimed_at, is_email_sent, expires_at, template_id)
11+
VALUES ('DAVE001', 'david@teleworm.us', 1, NOW(), NULL, NULL, false, NULL, 'user-office-registration-invitation-co-proposer');
12+
13+
SELECT invite_id
14+
INTO invite_id_var1
15+
FROM invites
16+
WHERE email = 'david@teleworm.us' AND code = 'DAVE001';
17+
18+
INSERT INTO invites (code, email, created_by, created_at, claimed_by, claimed_at, is_email_sent, expires_at, template_id)
19+
VALUES ('BEN001', 'ben@inbox.com', 1, NOW(), NULL, NULL, false, NULL, 'user-office-registration-invitation-co-proposer');
20+
21+
SELECT invite_id
22+
INTO invite_id_var2
23+
FROM invites
24+
WHERE email = 'ben@inbox.com' AND code = 'BEN001';
25+
26+
INSERT INTO co_proposer_claims (invite_id, proposal_pk) VALUES (invite_id_var1, 1);
27+
INSERT INTO co_proposer_claims (invite_id, proposal_pk) VALUES (invite_id_var2, 1);
28+
29+
INSERT INTO invites (code, email, created_by, created_at, claimed_by, claimed_at, is_email_sent, expires_at, template_id)
30+
VALUES ('DAVE002', 'david@teleworm.us', 1, NOW(), NULL, NULL, false, NULL, '');
31+
32+
SELECT invite_id
33+
INTO invite_id_var3
34+
FROM invites
35+
WHERE email = 'david@teleworm.us' AND code = 'DAVE002';
36+
37+
INSERT INTO invites (code, email, created_by, created_at, claimed_by, claimed_at, is_email_sent, expires_at, template_id)
38+
VALUES ('BEN002', 'ben@inbox.com', 1, NOW(), NULL, NULL, false, NULL, '');
39+
40+
SELECT invite_id
41+
INTO invite_id_var4
42+
FROM invites
43+
WHERE email = 'ben@inbox.com' AND code = 'BEN002';
44+
45+
INSERT INTO co_proposer_claims (invite_id, proposal_pk) VALUES (invite_id_var3, 2);
46+
INSERT INTO co_proposer_claims (invite_id, proposal_pk) VALUES (invite_id_var4, 2);
47+
48+
END;
49+
$DO$
50+
LANGUAGE plpgsql;

apps/backend/docker-compose-stfc.e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
clam-antivirus:
3-
image: clamav/clamav:0.104
3+
image: clamav/clamav:1.5.1
44
ports:
55
- "3310:3310"
66

@@ -40,13 +40,13 @@ services:
4040
- "4500:4500"
4141
cap_add:
4242
- SYS_ADMIN
43-
43+
4444
mockServer:
4545
image: mockserver/mockserver:5.13.0
4646
command: -logLevel ERROR -serverPort 1080
4747
ports:
4848
- 1080:1080
49-
49+
5050
mockserver-client:
5151
image: "ghcr.io/userofficeproject/stfc-mockserver-client:master"
5252
command: sh -c "sleep 5 && node src/mockserver.js"

apps/backend/example.development.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ EAM_API_URL=*******
1010
EAM_AUTH_USER=*******
1111
EAM_AUTH_PASSWORD=*******
1212
EAM_AUTH_TENANT=*******
13-
EAM_AUTH_ORGANIZATION=*******
13+
EAM_ORGANIZATION_CODE=*******
14+
EAM_ORGANIZATION_NAME=*******
15+
EAM_LOCATION_CODE=*******
1416
EAM_EQUIPMENT_PART_CODE=*******
1517

1618
# Graylog (Uncomment the variables to enable logging locally)

0 commit comments

Comments
 (0)