Skip to content

Commit

Permalink
fix login in prod (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairad26 authored Oct 24, 2024
1 parent e27f4ff commit cad31cf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions src/commands/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import {Command} from '@oclif/core'
import * as fs from 'node:fs'
import * as http from 'node:http'
import path, {dirname} from 'node:path'
import {createInterface} from 'node:readline'
import {fileURLToPath} from 'node:url'
import {URL} from 'node:url'
import open from 'open'

import {
fileExists, getEnvDir, getEnvFilePath, promptOrgSelection, sendGraphQLRequest,
} from '../../util/index.js'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
import loginHTML from './login-html.js'

export default class LoginIndex extends Command {
static override args = {}
Expand Down Expand Up @@ -39,10 +36,8 @@ export default class LoginIndex extends Command {

if (jwt && email) {
// Send response back to browser indicating success
const filePath = path.join(__dirname, 'login.html')
const content = fs.readFileSync(filePath, 'utf8')
res.writeHead(200, {'Content-Type': 'text/html'})
res.end(content)
res.end(loginHTML)

// Close the server once JWT and email are captured
server.close()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- src/commands/login/login.html -->
export default `<!-- src/commands/login/login.html -->
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -48,3 +48,4 @@ <h1>Authentication complete!</h1>
<p>You can now close this window and return to the terminal.</p>
</body>
</html>
`
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/index.ts","./src/commands/login/index.ts","./src/commands/logout/index.ts","./src/commands/org/switch.ts","./src/custom/help.ts","./src/util/index.ts"],"version":"5.6.2"}
{"root":["./src/index.ts","./src/commands/login/index.ts","./src/commands/login/login-html.ts","./src/commands/logout/index.ts","./src/commands/org/switch.ts","./src/custom/help.ts","./src/util/index.ts"],"version":"5.6.2"}

0 comments on commit cad31cf

Please sign in to comment.