mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-24 04:38:46 +00:00
fix: enhance invitation validation in authentication logic
- Updated the authentication process to check if the email of the user matches the email associated with the invitation token. - Improved error handling for cases where the user is not found or the email does not match the invitation.
This commit is contained in:
@@ -148,12 +148,17 @@ const { handler, api } = betterAuth({
|
|||||||
const xDokployToken =
|
const xDokployToken =
|
||||||
context?.request?.headers?.get("x-dokploy-token");
|
context?.request?.headers?.get("x-dokploy-token");
|
||||||
if (xDokployToken) {
|
if (xDokployToken) {
|
||||||
const user = await getUserByToken(xDokployToken);
|
const invitation = await getUserByToken(xDokployToken);
|
||||||
if (!user) {
|
if (!invitation) {
|
||||||
throw new APIError("BAD_REQUEST", {
|
throw new APIError("BAD_REQUEST", {
|
||||||
message: "User not found",
|
message: "User not found",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (_user.email !== invitation.email) {
|
||||||
|
throw new APIError("BAD_REQUEST", {
|
||||||
|
message: "Email does not match invitation",
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const isSSORequest = context?.path.includes("/sso");
|
const isSSORequest = context?.path.includes("/sso");
|
||||||
if (isSSORequest) {
|
if (isSSORequest) {
|
||||||
|
|||||||
Reference in New Issue
Block a user