Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Address greptile comment

Carlos Monastyrskid6d4b523b7bd
diff --git a/backend/src/services/auth/auth-password-service.ts b/backend/src/services/auth/auth-password-service.ts
index 7c8bd52624..21a51ef3f3 100644
--- a/backend/src/services/auth/auth-password-service.ts
+++ b/backend/src/services/auth/auth-password-service.ts
@@ -56,10 +56,10 @@ export const authPaswordServiceFactory = ({
if (!hasEmailAuth) {
const orgMemberships = await orgMembershipDAL.find({ userId: user.id });
const lastLoginMethod =
- orgMemberships.length > 0
- ? orgMemberships.find((membership) => membership.lastLoginAuthMethod)?.lastLoginAuthMethod || null
- : null;
-
+ orgMemberships
+ .filter((membership) => membership.lastLoginAuthMethod)
+ .sort((a, b) => (b.updatedAt || new Date(0)).getTime() - (a.updatedAt || new Date(0)).getTime())[0]
+ ?.lastLoginAuthMethod || null;
const substitutions = {
email,
lastLoginMethod,