@hsafa/cli 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/auth.js +7 -6
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -22,8 +22,10 @@ export function registerAuthCommands(program) {
|
|
|
22
22
|
});
|
|
23
23
|
async function loginBrowser() {
|
|
24
24
|
const serverUrl = config.get('serverUrl');
|
|
25
|
+
// Determine the client URL for authentication (NextAuth runs on the client)
|
|
26
|
+
const clientUrl = serverUrl.replace('server.hsafa.com', 'hsafa.com');
|
|
25
27
|
console.log(chalk.cyan('Authentication requested.'));
|
|
26
|
-
console.log(`We will open your browser to log you in to: ${
|
|
28
|
+
console.log(`We will open your browser to log you in to: ${clientUrl}`);
|
|
27
29
|
const { confirm } = await inquirer.prompt([
|
|
28
30
|
{
|
|
29
31
|
type: 'confirm',
|
|
@@ -73,14 +75,13 @@ export function registerAuthCommands(program) {
|
|
|
73
75
|
const port = address.port;
|
|
74
76
|
const callbackUrl = `http://localhost:${port}`;
|
|
75
77
|
// Open the browser
|
|
76
|
-
// Point to the
|
|
77
|
-
//
|
|
78
|
-
// The server page logic:
|
|
78
|
+
// Point to the client-side CLI login page (where NextAuth is configured)
|
|
79
|
+
// The client page logic:
|
|
79
80
|
// 1. Check if user is logged in (session).
|
|
80
|
-
// 2. If not, redirect to /auth/signin?callbackUrl=/cli-login?callback=callbackUrl
|
|
81
|
+
// 2. If not, redirect to /api/auth/signin?callbackUrl=/cli-login?callback=callbackUrl
|
|
81
82
|
// 3. If logged in, get session token.
|
|
82
83
|
// 4. Redirect to callbackUrl?token=sessionToken
|
|
83
|
-
const loginUrl = `${
|
|
84
|
+
const loginUrl = `${clientUrl}/cli-login?callback=${encodeURIComponent(callbackUrl)}`;
|
|
84
85
|
try {
|
|
85
86
|
await open(loginUrl);
|
|
86
87
|
}
|
package/dist/index.js
CHANGED