From dcacefd1960908cfc78ba55f3044d5349f4a7519 Mon Sep 17 00:00:00 2001
From: waldekmastykarz <waldek@mastykarz.nl>
Date: Tue, 5 Nov 2024 12:10:56 +0100
Subject: [PATCH] Fixes using env var for login. Closes #6469

---
 src/m365/commands/login.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/m365/commands/login.ts b/src/m365/commands/login.ts
index e07168eafd8..ad60b239b8e 100644
--- a/src/m365/commands/login.ts
+++ b/src/m365/commands/login.ts
@@ -50,8 +50,9 @@ class LoginCommand extends Command {
 
   public getRefinedSchema(schema: typeof options): z.ZodEffects<any> | undefined {
     return schema
-      .refine(options => typeof options.appId !== 'undefined' || cli.getConfig().get(settingsNames.clientId), {
-        message: `appId is required. TIP: use the "m365 setup" command to configure the default appId`
+      .refine(options => typeof options.appId !== 'undefined' || cli.getClientId(), {
+        message: `appId is required. TIP: use the "m365 setup" command to configure the default appId`,
+        path: ['appId']
       })
       .refine(options => options.authType !== 'password' || options.userName, {
         message: 'Username is required when using password authentication',