Merge pull request #3804 from Dokploy/3749-updating-the-basic-auth-account-password-did-not-update-the-traefik-middleware-configuration

feat: enhance security handling by adding refetch capability and impr…
This commit is contained in:
Mauricio Siu
2026-02-25 23:31:51 -06:00
committed by GitHub
3 changed files with 33 additions and 11 deletions
@@ -46,7 +46,7 @@ export const HandleSecurity = ({
}: Props) => { }: Props) => {
const utils = api.useUtils(); const utils = api.useUtils();
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const { data } = api.security.one.useQuery( const { data, refetch } = api.security.one.useQuery(
{ {
securityId: securityId ?? "", securityId: securityId ?? "",
}, },
@@ -88,6 +88,7 @@ export const HandleSecurity = ({
await utils.application.readTraefikConfig.invalidate({ await utils.application.readTraefikConfig.invalidate({
applicationId, applicationId,
}); });
await refetch();
setIsOpen(false); setIsOpen(false);
}) })
.catch(() => { .catch(() => {
+1 -1
View File
@@ -43,7 +43,7 @@ export const securityRouter = createTRPCRouter({
message: "You are not authorized to access this application", message: "You are not authorized to access this application",
}); });
} }
return await findSecurityById(input.securityId); return security;
}), }),
delete: protectedProcedure delete: protectedProcedure
.input(apiFindOneSecurity) .input(apiFindOneSecurity)
+30 -9
View File
@@ -50,7 +50,8 @@ export const createSecurity = async (
} catch (error) { } catch (error) {
throw new TRPCError({ throw new TRPCError({
code: "BAD_REQUEST", code: "BAD_REQUEST",
message: "Error creating this security", message:
error instanceof Error ? error.message : "Error creating this security",
cause: error, cause: error,
}); });
} }
@@ -90,15 +91,35 @@ export const updateSecurityById = async (
data: Partial<Security>, data: Partial<Security>,
) => { ) => {
try { try {
const response = await db await db.transaction(async (tx) => {
.update(security) const securityResponse = await findSecurityById(securityId);
.set({
...data,
})
.where(eq(security.securityId, securityId))
.returning();
return response[0]; const application = await findApplicationById(
securityResponse.applicationId,
);
await removeSecurityMiddleware(application, securityResponse);
const response = await tx
.update(security)
.set({
...data,
})
.where(eq(security.securityId, securityId))
.returning()
.then((res) => res[0]);
if (!response) {
throw new TRPCError({
code: "NOT_FOUND",
message: "Security not found",
});
}
await createSecurityMiddleware(application, response);
return response;
});
} catch (error) { } catch (error) {
const message = const message =
error instanceof Error ? error.message : "Error updating this security"; error instanceof Error ? error.message : "Error updating this security";