mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02: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 =
|
||||
context?.request?.headers?.get("x-dokploy-token");
|
||||
if (xDokployToken) {
|
||||
const user = await getUserByToken(xDokployToken);
|
||||
if (!user) {
|
||||
const invitation = await getUserByToken(xDokployToken);
|
||||
if (!invitation) {
|
||||
throw new APIError("BAD_REQUEST", {
|
||||
message: "User not found",
|
||||
});
|
||||
}
|
||||
if (_user.email !== invitation.email) {
|
||||
throw new APIError("BAD_REQUEST", {
|
||||
message: "Email does not match invitation",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const isSSORequest = context?.path.includes("/sso");
|
||||
if (isSSORequest) {
|
||||
|
||||
Reference in New Issue
Block a user