mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-13 15:35:17 +00:00
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:
@@ -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(() => {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
Reference in New Issue
Block a user