Skip to content

Commit 3a47fc9

Browse files
committed
Always update password
1 parent 68d8ebb commit 3a47fc9

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

packages/server/api/src/app/database/seeds/seed-admin.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
import { AppSystemProp, logger, system } from '@openops/server-shared';
66
import { OrganizationRole, Provider, User } from '@openops/shared';
77
import { authenticationService } from '../../authentication/basic/authentication-service';
8-
import { passwordHasher } from '../../authentication/basic/password-hasher';
98
import { openopsTables } from '../../openops-tables';
109
import { authenticateAdminUserInOpenOpsTables } from '../../openops-tables/auth-admin-tables';
1110
import { organizationService } from '../../organization/organization.service';
@@ -168,23 +167,16 @@ async function upsertAdminPassword(
168167
user: User,
169168
newPassword: string,
170169
): Promise<void> {
171-
const passwordMatches = await passwordHasher.compare(
172-
newPassword,
173-
user.password,
174-
);
175-
176-
if (!passwordMatches) {
177-
const email = user.email;
178-
logger.info(`Updating password for admin [${email}]`, email);
170+
const email = user.email;
171+
logger.info(`Updating password for admin [${email}]`, email);
179172

180-
const updatedUser = await userService.updatePassword({
181-
id: user.id,
182-
newPassword,
183-
});
173+
const updatedUser = await userService.updatePassword({
174+
id: user.id,
175+
newPassword,
176+
});
184177

185-
const { token } = await authenticateUserInOpenOpsTables(email, newPassword);
186-
await resetUserPassword(email, updatedUser.password, token);
187-
}
178+
const { token } = await authenticateUserInOpenOpsTables(email, newPassword);
179+
await resetUserPassword(email, updatedUser.password, token);
188180
}
189181

190182
async function upsertAdminEmail(user: User, email: string): Promise<void> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('create-user', () => {
8383
expect(createTablesUserMock).toHaveBeenCalledWith({
8484
name: 'John Doe',
8585
email: baseParams.email,
86-
password: 'P@ssw0rd',
86+
password: res.user.password,
8787
authenticate: true,
8888
});
8989

0 commit comments

Comments
 (0)