Skip to content

Commit bf6d23c

Browse files
authored
Fix the creation of Tables users when using random passwords (#1595)
Part of OPS-3003.
1 parent 38c5293 commit bf6d23c

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/server/api/src/app/authentication/new-user/create-user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export async function createUserWithRandomPassword(
158158
const tablesRefreshToken = await createTablesUser(
159159
name,
160160
params.email,
161-
randomPassword,
161+
user.password,
162162
);
163163

164164
return {

packages/server/api/src/app/user/user-service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ export const userService = {
160160
.getMany();
161161
},
162162

163+
async getUserByEmail(email: string): Promise<User | null> {
164+
const cleanedEmail = email.toLowerCase().trim();
165+
return userRepo().findOneBy({ email: cleanedEmail });
166+
},
167+
163168
async getByOrganizationAndEmail({
164169
organizationId,
165170
email,

packages/server/api/test/unit/authentication/new-user/create-user.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ describe('create-user', () => {
135135
const createdUser = {
136136
id: 'u3',
137137
organizationId: baseParams.organizationId,
138+
password: '12345678',
138139
};
139140
createUserServiceMock.mockResolvedValue(createdUser);
140141
createTablesUserMock.mockResolvedValue({ refresh_token: 't2' });
@@ -146,7 +147,7 @@ describe('create-user', () => {
146147
);
147148

148149
expect(createTablesUserMock).toHaveBeenCalledWith(
149-
expect.objectContaining({ password: 'Rand#123' }),
150+
expect.objectContaining({ password: '12345678' }),
150151
);
151152

152153
expect(res).toEqual({ user: createdUser, tablesRefreshToken: 't2' });

0 commit comments

Comments
 (0)