Skip to content

Commit 3526812

Browse files
committed
authflow: brand the CLI login callback page with the memcode wordmark
The 'Authenticated / close this tab' page was bare system-font text. Add the hosted memcode wordmark (referenced by absolute URL — the browser just OAuth'd against memcode.ai, so it has connectivity, and a 300KB PNG shouldn't inflate the binary), a proper doctype/viewport, tightened typography, and a subtle fade-in. HTML-escape the error message while here.
1 parent 948de4e commit 3526812

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

internal/authflow/authflow.go

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"crypto/rand"
1111
"encoding/hex"
1212
"fmt"
13+
"html"
1314
"io"
1415
"net"
1516
"net/http"
@@ -253,19 +254,47 @@ func StripGlobalEnvToken() (bool, error) {
253254
return true, nil
254255
}
255256

257+
// callbackWordmark is the hosted memcode wordmark (the matrix glyph mark from
258+
// the marketing site). Referenced by absolute URL rather than embedded: the
259+
// browser rendering this page just completed OAuth against memcode.ai, so it
260+
// has connectivity, and a 300KB PNG has no business inflating the binary. If
261+
// the fetch fails the alt text still reads "memcode".
262+
const callbackWordmark = "https://memcode.ai/logo-wordmark.png"
263+
256264
func writeCallbackPage(w http.ResponseWriter, ok bool, errMsg string) {
257-
w.Header().Set("Content-Type", "text/html")
265+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
258266
if !ok {
259267
w.WriteHeader(http.StatusBadRequest)
260268
}
261-
body := `<html><body style="font-family:system-ui;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:#0a0a0a;color:#fafafa"><div style="text-align:center">`
269+
270+
var inner string
262271
if ok {
263-
body += `<h2>Authenticated</h2><p style="color:#888">You can close this tab and return to your terminal.</p>`
272+
inner = `<h1>Authenticated</h1><p class="sub">You can close this tab and return to your terminal.</p>`
264273
} else {
265-
body += fmt.Sprintf(`<h2>Authentication failed</h2><p style="color:#f87171">%s</p><p style="color:#888">Close this tab and try again.</p>`, errMsg)
274+
inner = fmt.Sprintf(
275+
`<h1>Authentication failed</h1><p class="err">%s</p><p class="sub">Close this tab and try again.</p>`,
276+
html.EscapeString(errMsg),
277+
)
266278
}
267-
body += `</div></body></html>`
268-
io.WriteString(w, body)
279+
280+
page := `<!doctype html><html lang="en"><head><meta charset="utf-8">` +
281+
`<meta name="viewport" content="width=device-width,initial-scale=1"><title>memcode</title><style>` +
282+
`html,body{height:100%}` +
283+
`body{margin:0;background:#0a0a0a;color:#fafafa;` +
284+
`font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;` +
285+
`display:flex;align-items:center;justify-content:center}` +
286+
`.wrap{text-align:center;padding:24px;animation:fade .5s ease both}` +
287+
`.mark{width:200px;max-width:56vw;height:auto;display:block;margin:0 auto 40px;opacity:.95}` +
288+
`h1{margin:0 0 10px;font-size:28px;font-weight:600;letter-spacing:-.02em}` +
289+
`.sub{margin:0;color:#8a8a8a;font-size:15px}` +
290+
`.err{margin:0 0 6px;color:#f87171;font-size:15px}` +
291+
`@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}` +
292+
`</style></head><body><div class="wrap">` +
293+
`<img class="mark" src="` + callbackWordmark + `" alt="memcode">` +
294+
inner +
295+
`</div></body></html>`
296+
297+
io.WriteString(w, page)
269298
}
270299

271300
// envOr returns os.Getenv(key) or fallback if empty.

0 commit comments

Comments
 (0)