mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 12:28:56 +00:00
Fix incorrect field in validateProviderAuthToken
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { User } from "../../models";
|
import { AuthMethod, User } from "../../models";
|
||||||
import { checkEmailVerification, sendEmailVerification } from "../../helpers/signup";
|
import { checkEmailVerification, sendEmailVerification } from "../../helpers/signup";
|
||||||
import { createToken } from "../../helpers/auth";
|
import { createToken } from "../../helpers/auth";
|
||||||
import { BadRequestError } from "../../utils/errors";
|
import { BadRequestError } from "../../utils/errors";
|
||||||
@@ -81,7 +81,8 @@ export const verifyEmailSignup = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
user = await new User({
|
user = await new User({
|
||||||
email
|
email,
|
||||||
|
authMethods: [AuthMethod.EMAIL]
|
||||||
}).save();
|
}).save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,17 @@ export const completeAccountSignup = async (req: Request, res: Response) => {
|
|||||||
if (!user)
|
if (!user)
|
||||||
throw new Error("Failed to complete account for non-existent user"); // ensure user is non-null
|
throw new Error("Failed to complete account for non-existent user"); // ensure user is non-null
|
||||||
|
|
||||||
if (!user.authMethods?.includes(AuthMethod.OKTA_SAML)) {
|
const hasSamlEnabled = user.authMethods
|
||||||
|
.some(
|
||||||
|
(authMethod: AuthMethod) =>
|
||||||
|
[
|
||||||
|
AuthMethod.OKTA_SAML,
|
||||||
|
AuthMethod.AZURE_SAML,
|
||||||
|
AuthMethod.JUMPCLOUD_SAML
|
||||||
|
].includes(authMethod)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasSamlEnabled) { // TODO: modify this part
|
||||||
// initialize default organization and workspace
|
// initialize default organization and workspace
|
||||||
await initializeDefaultOrg({
|
await initializeDefaultOrg({
|
||||||
organizationName,
|
organizationName,
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ export const validateProviderAuthToken = async ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!user.authMethods.includes(decodedToken.authProvider) ||
|
!user.authMethods.includes(decodedToken.authMethod) ||
|
||||||
decodedToken.email !== email
|
decodedToken.email !== email
|
||||||
) {
|
) {
|
||||||
throw new Error("Invalid authentication credentials.")
|
throw new Error("Invalid authentication credentials.")
|
||||||
|
|||||||
Reference in New Issue
Block a user