feat(password-update): enhance password update functionality across database routers

- Added confirmation password field and validation to the `UpdateDatabasePassword` component.
- Refactored password update logic in MariaDB, MongoDB, MySQL, Postgres, and Redis routers to utilize database transactions for improved reliability.
- Ensured consistent handling of password updates across all database types, enhancing user experience and security.
This commit is contained in:
Mauricio Siu
2026-04-04 09:19:29 -06:00
parent 1506d8f21e
commit 3d838aa074
6 changed files with 92 additions and 45 deletions

View File

@@ -424,13 +424,19 @@ export const postgresRouter = createTRPCRouter({
fi
docker exec "$CONTAINER_ID" psql -U ${databaseUser} -c "ALTER USER \\"${databaseUser}\\" WITH PASSWORD '${password}';"
`;
if (serverId) {
await execAsyncRemote(serverId, command);
} else {
await execAsync(command, { shell: "/bin/bash" });
}
await updatePostgresById(postgresId, { databasePassword: password });
await db.transaction(async (tx) => {
await tx
.update(postgresTable)
.set({ databasePassword: password })
.where(eq(postgresTable.postgresId, postgresId));
if (serverId) {
await execAsyncRemote(serverId, command);
} else {
await execAsync(command, { shell: "/bin/bash" });
}
});
await audit(ctx, {
action: "update",