Skip to content

Commit 912eeaa

Browse files
authored
Merge pull request #27 from kodado/add--remove-companyName-from-user
Add remove company name from user
2 parents 6c6b1fd + fed7d59 commit 912eeaa

File tree

11 files changed

+9
-69
lines changed

11 files changed

+9
-69
lines changed

docs/authenticating.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ The `signUp` function registers a new user and derives encryption keys from the
1414

1515
```typescript
1616
await client.auth.signUp({
17-
email: "john.doe@example.com",
18-
password: "SecurePassword123!",
19-
username: "johndoe",
20-
fullName: "John Doe",
21-
companyName: "Example Corp",
17+
email: "john.doe@example.com",
18+
password: "SecurePassword123!",
19+
username: "johndoe",
20+
fullName: "John Doe",
2221
});
2322
```
2423

@@ -28,8 +27,8 @@ The `signIn` function authenticates an existing user using the SRP protocol.
2827

2928
```typescript
3029
await client.auth.signIn({
31-
email: "john.doe@example.com",
32-
password: "SecurePassword123!",
30+
email: "john.doe@example.com",
31+
password: "SecurePassword123!",
3332
});
3433
```
3534

@@ -39,8 +38,8 @@ The `updatePassword` function allows a user to change their password.
3938

4039
```typescript
4140
await client.auth.updatePassword({
42-
oldPassword: "SecurePassword123!",
43-
newPassword: "NewSecurePassword456!",
41+
oldPassword: "SecurePassword123!",
42+
newPassword: "NewSecurePassword456!",
4443
});
4544
```
4645

src/auth/AuthApiClient.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,16 @@ export class AuthApiClient {
5050

5151
async updateUserProfile({
5252
fullName,
53-
companyName,
5453
emailNotifications,
5554
token,
5655
}: {
5756
fullName?: string;
58-
companyName?: string;
5957
emailNotifications?: string;
6058
token: string;
6159
}) {
6260
await fetch(`${this.endpoint}/auth/profile`, {
6361
method: "PUT",
64-
body: JSON.stringify({ fullName, companyName, emailNotifications }),
62+
body: JSON.stringify({ fullName, emailNotifications }),
6563
headers: {
6664
Authorization: token,
6765
},

src/auth/AuthClient.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export type User = {
3333
nickname: string;
3434
fullName: string;
3535
imageUrl: string;
36-
companyName: string;
3736
emailNotifications?: Record<string, boolean>;
3837
userId: string;
3938
keys: Keys;
@@ -102,7 +101,6 @@ export class AuthClient {
102101
nickname: idToken.payload.nickname,
103102
fullName: idToken.payload.name,
104103
imageUrl: profile.imageUrl,
105-
companyName: idToken.payload["custom:companyName"],
106104
emailNotifications: idToken.payload["custom:emailNotifications"]
107105
? JSON.parse(idToken.payload["custom:emailNotifications"])
108106
: {},
@@ -166,7 +164,6 @@ export class AuthClient {
166164
nickname: idToken.payload.nickname,
167165
fullName: idToken.payload.name,
168166
imageUrl,
169-
companyName: idToken.payload["custom:companyName"],
170167
emailNotifications: idToken.payload["custom:emailNotifications"]
171168
? JSON.parse(idToken.payload["custom:emailNotifications"])
172169
: {},
@@ -203,13 +200,11 @@ export class AuthClient {
203200
password,
204201
nickname,
205202
fullName,
206-
companyName,
207203
}: {
208204
email: string;
209205
password: string;
210206
nickname: string;
211207
fullName?: string;
212-
companyName?: string;
213208
}) {
214209
const keys = generateKeys();
215210
const encryptedPrivateKeys: string = encryptPrivateKeys(keys, password);
@@ -221,7 +216,6 @@ export class AuthClient {
221216
nickname,
222217
encryptedPrivateKeys,
223218
fullName,
224-
companyName,
225219
});
226220
} catch (e) {
227221
throw new UsernameAlreadyExistsError();
@@ -230,7 +224,6 @@ export class AuthClient {
230224
const userData = {
231225
username: nickname,
232226
fullName,
233-
companyName,
234227
appId: "testApp",
235228
encryptionPublicKey: encodeBase64(keys.encryptionPublicKey),
236229
signPublicKey: encodeBase64(keys.signPublicKey),
@@ -245,29 +238,24 @@ export class AuthClient {
245238

246239
async updateProfile({
247240
fullName,
248-
companyName,
249241
emailNotifications,
250242
}: {
251243
fullName?: string;
252-
companyName?: string;
253244
emailNotifications?: Record<string, boolean>;
254245
}) {
255246
if (!this.user || !this.session) return;
256247

257248
await this.apiClient.updateUserProfile({
258249
fullName,
259-
companyName,
260250
emailNotifications: JSON.stringify(emailNotifications),
261251
token: (await this.getCurrentAuthorizationToken()) || "",
262252
});
263253
await this.cognitoClient.updateCognitoProfile(this.session, {
264254
fullName,
265-
companyName,
266255
emailNotifications: JSON.stringify(emailNotifications),
267256
});
268257

269258
this.user.fullName = fullName || this.user.fullName;
270-
this.user.companyName = companyName || this.user.companyName;
271259
this.user.emailNotifications =
272260
emailNotifications || this.user.emailNotifications;
273261
}
@@ -485,7 +473,6 @@ export class AuthClient {
485473
nickname: idToken.payload.nickname,
486474
fullName: idToken.payload.name,
487475
imageUrl,
488-
companyName: idToken.payload["custom:companyName"],
489476
emailNotifications: idToken.payload["custom:emailNotifications"]
490477
? JSON.parse(idToken.payload["custom:emailNotifications"])
491478
: {},

src/auth/CognitoClient.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type UserAttributes = {
1717
password: string;
1818
encryptedPrivateKeys?: string;
1919
fullName?: string;
20-
companyName?: string;
2120
};
2221

2322
type UserPool = {
@@ -104,7 +103,6 @@ export class CognitoClient {
104103
password,
105104
encryptedPrivateKeys,
106105
fullName,
107-
companyName,
108106
}: UserAttributes): Promise<ISignUpResult | undefined> {
109107
const userPool = new CognitoUserPool(this.userpool);
110108

@@ -130,15 +128,6 @@ export class CognitoClient {
130128
);
131129
}
132130

133-
if (companyName) {
134-
userAttributes.push(
135-
new CognitoUserAttribute({
136-
Name: "custom:companyName",
137-
Value: companyName,
138-
})
139-
);
140-
}
141-
142131
return new Promise((res, rej) => {
143132
userPool.signUp(
144133
username,
@@ -185,11 +174,9 @@ export class CognitoClient {
185174
session: CognitoUserSession,
186175
{
187176
fullName,
188-
companyName,
189177
emailNotifications,
190178
}: {
191179
fullName?: string;
192-
companyName?: string;
193180
emailNotifications?: string;
194181
}
195182
) {
@@ -213,15 +200,6 @@ export class CognitoClient {
213200
);
214201
}
215202

216-
if (companyName) {
217-
attributes.push(
218-
new CognitoUserAttribute({
219-
Name: "custom:companyName",
220-
Value: companyName,
221-
})
222-
);
223-
}
224-
225203
if (emailNotifications) {
226204
attributes.push(
227205
new CognitoUserAttribute({

test/auth.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const credentials = getUserCredentials({
2828
password: "Abcd1234!",
2929
username: "auth-lib-user",
3030
fullName: "Auth Lib User",
31-
companyName: "CompanyXYZ",
3231
});
3332

3433
beforeAll(async () => {
@@ -69,7 +68,6 @@ describe("signIn", () => {
6968
expect(user.email).toBe(credentials.email);
7069
expect(user.nickname).toBe(credentials.username);
7170
expect(user.fullName).toBe(credentials.fullName);
72-
expect(user.companyName).toBe(credentials.companyName);
7371
expect(user).toHaveProperty("keys");
7472
expect(user).toHaveProperty("keys.encryptionPublicKey");
7573
expect(user).toHaveProperty("keys.encryptionSecretKey");
@@ -119,7 +117,6 @@ describe("updateProfile", () => {
119117

120118
await client.auth.updateProfile({
121119
fullName: "updated fullName",
122-
companyName: "updated companyName",
123120
emailNotifications: { type1: true, type2: false },
124121
});
125122

@@ -132,7 +129,6 @@ describe("updateProfile", () => {
132129
}
133130

134131
expect(session.fullName).toBe("updated fullName");
135-
expect(session.companyName).toBe("updated companyName");
136132
expect(session.emailNotifications).toEqual({ type1: true, type2: false });
137133

138134
client.auth.signOut();

test/bulkCreateItem.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ beforeAll(async () => {
2424
password: "Abcd1234!",
2525
username: "bulkCreate1",
2626
fullName: "Bulk Create 1",
27-
companyName: "Company 1",
2827
});
2928

3029
await recreateUser(client, {
3130
email: "bulkCreate2@turingpoint.de",
3231
password: "Abcd1234!",
3332
username: "bulkCreate2",
3433
fullName: "Bulk Create 2",
35-
companyName: "Company 2",
3634
});
3735

3836
await client.auth.signIn({

test/bulkRevokeItem.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ beforeAll(async () => {
2424
password: "Abcd1234!",
2525
username: "bulkRevoke1",
2626
fullName: "Bulk Revoke 1",
27-
companyName: "Company 1",
2827
});
2928

3029
await recreateUser(client, {
3130
email: "bulkRevoke2@turingpoint.de",
3231
password: "Abcd1234!",
3332
username: "bulkRevoke2",
3433
fullName: "Bulk Revoke 2",
35-
companyName: "Company 2",
3634
});
3735

3836
await client.auth.signIn({

test/deepShare.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,20 @@ beforeAll(async () => {
3131
password: "Abcd1234!",
3232
username: "deepShare1",
3333
fullName: "Deep Share 1",
34-
companyName: "Company 1",
3534
});
3635

3736
await recreateUser(client, {
3837
email: "deepShare2@turingpoint.de",
3938
password: "Abcd1234!",
4039
username: "deepShare2",
4140
fullName: "Deep Share 2",
42-
companyName: "Company 2",
4341
});
4442

4543
await recreateUser(client, {
4644
email: "deepShare3@turingpoint.de",
4745
password: "Abcd1234!",
4846
username: "deepShare3",
4947
fullName: "Deep Share 3",
50-
companyName: "Company 1",
5148
});
5249

5350
await client.auth.signIn({
@@ -190,7 +187,6 @@ describe("shareItem", () => {
190187
username
191188
role
192189
fullName
193-
companyName
194190
}
195191
createdAt
196192
}
@@ -211,13 +207,11 @@ describe("shareItem", () => {
211207
username: "deepShare2",
212208
role: "member",
213209
fullName: "Deep Share 2",
214-
companyName: "Company 2",
215210
},
216211
{
217212
username: "deepShare1",
218213
role: "owner",
219214
fullName: "Deep Share 1",
220-
companyName: "Company 1",
221215
},
222216
])
223217
);

test/helpers/createUser.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export type Credentials = {
55
password: string;
66
username: string;
77
fullName?: string;
8-
companyName?: string;
98
};
109

1110
export async function safelyDeleteUser(
@@ -36,7 +35,6 @@ export async function recreateUser(
3635
password: credentials.password,
3736
nickname: credentials.username,
3837
fullName: credentials.fullName,
39-
companyName: credentials.companyName,
4038
});
4139
}
4240

@@ -49,7 +47,6 @@ export function getUserCredentials(credentials: Credentials) {
4947
username: `${prefix}-${credentials.username}`,
5048
password: credentials.password,
5149
fullName: credentials.fullName,
52-
companyName: credentials.companyName,
5350
};
5451

5552
return prefixedCredentials;

test/publicKeyStorage.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ beforeAll(async () => {
2121
password: "Abcd1234!",
2222
username: "publicKeyStorage1",
2323
fullName: "Deep Share 1",
24-
companyName: "Company 1",
2524
});
2625

2726
await recreateUser(client, {
2827
email: "publicKeyStorage2@turingpoint.de",
2928
password: "Abcd1234!",
3029
username: "publicKeyStorage2",
3130
fullName: "Deep Share 2",
32-
companyName: "Company 2",
3331
});
3432
});
3533

0 commit comments

Comments
 (0)