Skip to content

Commit 1c1d01d

Browse files
authored
BREAKING CHANGE: remove gender, telephone, username, position, placeholder, birthdate … (#1126)
2 parents a2f15d2 + 0eabcd4 commit 1c1d01d

77 files changed

Lines changed: 207 additions & 2261 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.

apps/backend/db_patches/0181_RemoveUserColumns.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ BEGIN
99
'2025-05-12'
1010
) THEN
1111
BEGIN
12+
DELETE FROM features WHERE feature_id = 'EMAIL_INVITE_LEGACY';
13+
DROP TABLE IF EXISTS public.redeem_codes;
1214
-- first drop the FK on nationality
1315
ALTER TABLE public.users
1416
DROP CONSTRAINT IF EXISTS users_nationality_fkey;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- 0181_RemoveUserColumns.sql
2+
DO
3+
$$
4+
BEGIN
5+
IF register_patch(
6+
'0182_RemoveUserColumns2.sql',
7+
'Fredrik Bolmsten',
8+
'Remove gender, telephone, username, position, placeholder, birthdate and department columns from users table',
9+
'2025-05-12'
10+
) THEN
11+
BEGIN
12+
-- now drop the unwanted columns
13+
ALTER TABLE public.users
14+
DROP COLUMN username,
15+
DROP COLUMN gender,
16+
DROP COLUMN birthdate,
17+
DROP COLUMN department,
18+
DROP COLUMN position,
19+
DROP COLUMN telephone;
20+
END;
21+
END IF;
22+
END;
23+
$$
24+
LANGUAGE plpgsql;

apps/backend/db_patches/db_seeds/0002_InstrumentScientists.sql

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@ $DO$
33
BEGIN
44

55
INSERT INTO users(
6-
user_id, user_title, firstname, lastname, username, preferredname, oidc_sub, oauth_refresh_token, gender, birthdate, department, "position", email,
7-
telephone, created_at, updated_at, institution_id, placeholder)
8-
VALUES (100, '', 'Instrument', 'Scientist1', 'instr.sci1', '-', 'instr.sci1.oauthsub', 'dummy-refresh-token', 'e2e user', '2020-10-10', 'IT', '', 'instr.sci1@local.host', '', NOW(), NOW(), 1, false);
6+
user_id, user_title, firstname, lastname, preferredname, oidc_sub, oauth_refresh_token, email, created_at, updated_at, institution_id
7+
)
8+
VALUES (100, '', 'Instrument', 'Scientist1', '-', 'instr.sci1.oauthsub', 'dummy-refresh-token', 'instr.sci1@local.host', NOW(), NOW(), 1);
99

1010
INSERT INTO users(
11-
user_id, user_title, firstname, lastname, username, preferredname, oidc_sub, oauth_refresh_token, gender, birthdate, department, "position", email,
12-
telephone, created_at, updated_at, institution_id, placeholder)
13-
VALUES (101, '', 'Instrument', 'Scientist2', 'instr.sci2', '-', 'instr.sci2.oauthsub', 'dummy-refresh-token', 'e2e user', '2020-10-10', 'IT', '', 'instr.sci2@local.host', '', NOW(), NOW(), 1, false);
11+
user_id, user_title, firstname, lastname, preferredname, oidc_sub, oauth_refresh_token, email, created_at, updated_at, institution_id
12+
)
13+
VALUES (101, '', 'Instrument', 'Scientist2', '-', 'instr.sci2.oauthsub', 'dummy-refresh-token', 'instr.sci2@local.host', NOW(), NOW(), 1);
1414

1515
-- user account with every roles except instrument scientist and user officer
1616
INSERT INTO users(
17-
user_id, user_title, firstname, lastname, username, preferredname, oidc_sub, oauth_refresh_token, gender, birthdate, department, "position", email,
18-
telephone, created_at, updated_at, institution_id, placeholder)
19-
VALUES (102, '', 'Not', 'Scientist', 'not.instr.sci', '-', 'not.instr.sci.oauthsub', 'dummy-refresh-token', 'e2e user', '2020-10-10', 'IT', '', 'not.instr.sci@local.host', '', NOW(), NOW(), 1, false);
17+
user_id, user_title, firstname, lastname, preferredname, oidc_sub, oauth_refresh_token, email, created_at, updated_at, institution_id
18+
)
19+
VALUES (102, '', 'Not', 'Scientist', '-', 'not.instr.sci.oauthsub', 'dummy-refresh-token', 'not.instr.sci@local.host', NOW(), NOW(), 1);
2020

2121
-- user account with experiment safety reviewer
2222
INSERT INTO users(
23-
user_id, user_title, firstname, lastname, username, preferredname, oidc_sub, oauth_refresh_token, gender, birthdate, department, "position", email,
24-
telephone, created_at, updated_at, institution_id, placeholder)
25-
VALUES (103, '', 'Experiment', 'Safety', 'experiment.safety', '-', 'experiment.safety.oauthsub', 'dummy-refresh-token', 'e2e user', '2020-10-10', 'IT', '', 'experiment.safety@local.host', '', NOW(), NOW(), 1, false);
23+
user_id, user_title, firstname, lastname, preferredname, oidc_sub, oauth_refresh_token, email, created_at, updated_at, institution_id)
24+
VALUES (103, '', 'Experiment', 'Safety', 'experiment.safety', 'experiment.safety.oauthsub', 'dummy-refresh-token', 'experiment.safety@local.host', NOW(), NOW(), 1);
2625

2726
INSERT INTO role_user(
2827
role_id, user_id)

apps/backend/db_patches/db_seeds/0006_RedeemCodes.sql

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/backend/docker-compose.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
services:
2-
duo-cron-job:
3-
image: ghcr.io/userofficeproject/user-office-cron:develop
4-
environment:
5-
API_URL: http://host.docker.internal:4000/graphql
6-
API_AUTH_TOKEN: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoyLCJ1c2VyX3RpdGxlIjoiTXIuIiwiZmlyc3RuYW1lIjoiQW5kZXJzIiwibWlkZGxlbmFtZSI6IkFkYW0iLCJsYXN0bmFtZSI6IkFuZGVyc3NvbiIsInVzZXJuYW1lIjoidGVzdG9mZmljZXIiLCJwcmVmZXJyZWRuYW1lIjoiUmhpYW5ub24iLCJvcmNpZCI6Ijg3ODMyMTg5NyIsImdlbmRlciI6Im1hbGUiLCJuYXRpb25hbGl0eSI6IkZyZW5jaCIsImJpcnRoZGF0ZSI6IjE5ODEtMDgtMDRUMjI6MDA6MDAuMDAwWiIsIm9yZ2FuaXNhdGlvbiI6IlBmYW5uZXJzdGlsbCBhbmQgU29ucyIsImRlcGFydG1lbnQiOiJJVCBkZXBhcnRtZW50Iiwib3JnYW5pc2F0aW9uX2FkZHJlc3MiOiJDb25nbywgQWxsZW5ldmlsbGUsIDM1ODIzIE11ZWxsZXIgR2xlbnMiLCJwb3NpdGlvbiI6IkxpYWlzb24iLCJlbWFpbCI6IkFhcm9uX0hhcnJpczQ5QGdtYWlsLmNvbSIsImVtYWlsVmVyaWZpZWQiOnRydWUsInRlbGVwaG9uZSI6IjcxMS0zMTYtNTcyOCIsInRlbGVwaG9uZV9hbHQiOiIxLTM1OS04NjQtMzQ4OSB4NzM5MCIsImNyZWF0ZWQiOiIyMDE5LTEwLTE3VDEwOjU4OjM4LjczNVoiLCJ1cGRhdGVkIjoiMjAxOS0xMC0xN1QxMDo1ODozOC43MzVaIn0sInJvbGVzIjpbeyJpZCI6Miwic2hvcnRDb2RlIjoidXNlcl9vZmZpY2VyIiwidGl0bGUiOiJVc2VyIE9mZmljZXIifV0sImlhdCI6MTU3MTMyNzQ2Mn0.NinmUuwuu0D6syqwd2z5J1BaqhwRPlFaxtML8sA2Ang
7-
82
db:
93
image: postgres:16-alpine
104
restart: always

apps/backend/package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@user-office-software/duo-localisation": "^1.2.0",
4848
"@user-office-software/duo-logger": "^2.3.2",
4949
"@user-office-software/duo-message-broker": "^1.8.0",
50-
"@user-office-software/duo-validation": "^5.1.20",
50+
"@user-office-software/duo-validation": "^5.1.22",
5151
"@user-office-software/openid": "^1.4.0",
5252
"await-to-js": "^2.1.1",
5353
"bcryptjs": "^2.4.3",

apps/backend/src/auth/OAuthAuthorization.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,14 @@ export class OAuthAuthorization extends UserAuthorization {
141141
if (user) {
142142
const updatedUser = await this.userDataSource.update({
143143
...user,
144-
birthdate: userInfo.birthdate
145-
? new Date(userInfo.birthdate)
146-
: undefined,
147-
department: userInfo.department as string,
148144
email: userInfo.email,
149145
firstname: userInfo.given_name,
150-
gender: userInfo.gender,
151146
lastname: userInfo.family_name,
152147
oauthIssuer: client.issuer.metadata.issuer,
153148
oauthRefreshToken: tokenSet.refresh_token ?? '',
154149
oidcSub: userInfo.sub,
155150
institutionId: institution?.id ?? user.institutionId,
156-
position: userInfo.position as string,
157151
preferredname: userInfo.preferred_username,
158-
telephone: userInfo.phone_number,
159152
user_title: userInfo.title as string,
160153
});
161154

@@ -165,18 +158,12 @@ export class OAuthAuthorization extends UserAuthorization {
165158
(userInfo.title as string) ?? 'unspecified',
166159
userInfo.given_name,
167160
userInfo.family_name,
168-
userInfo.email,
169161
userInfo.preferred_username ?? '',
170162
userInfo.sub,
171163
tokenSet.refresh_token ?? '',
172164
client.issuer.metadata.issuer,
173-
userInfo.gender ?? 'unspecified',
174-
new Date(),
175165
institution?.id ?? 1,
176-
'',
177-
(userInfo.position as string) ?? '',
178-
userInfo.email,
179-
''
166+
userInfo.email
180167
);
181168

182169
const roleID = this.getUserRole(newUser);

apps/backend/src/buildContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import PredefinedMessageMutations from './mutations/PredefinedMessageMutations';
2020
import ProposalMutations from './mutations/ProposalMutations';
2121
import ProposalPdfTemplateMutations from './mutations/ProposalPdfTemplateMutations';
2222
import QuestionaryMutations from './mutations/QuestionaryMutations';
23-
import RedeemCodesMutations from './mutations/RedeemCodesMutations';
2423
import ReviewMutations from './mutations/ReviewMutations';
2524
import SampleMutations from './mutations/SampleMutations';
2625
import ShipmentMutations from './mutations/ShipmentMutations';
@@ -120,7 +119,6 @@ const context: BasicResolverContext = {
120119
),
121120
proposal: container.resolve(ProposalMutations),
122121
questionary: container.resolve(QuestionaryMutations),
123-
redeemCodes: container.resolve(RedeemCodesMutations),
124122
review: container.resolve(ReviewMutations),
125123
sample: container.resolve(SampleMutations),
126124
fap: container.resolve(FapMutations),

apps/backend/src/config/Tokens.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const Tokens = {
3030
ProposalSettingsDataSource: Symbol('ProposalSettingsDataSource'),
3131
StatusActionsDataSource: Symbol('StatusActionsDataSource'),
3232
QuestionaryDataSource: Symbol('QuestionaryDataSource'),
33-
RedeemCodesDataSource: Symbol('RedeemCodesDataSource'),
3433
RoleClaimDataSource: Symbol('RoleClaimDataSource'),
3534
ReviewDataSource: Symbol('ReviewDataSource'),
3635
FapDataSource: Symbol('FapDataSource'),

0 commit comments

Comments
 (0)