MCPcopy Index your code
hub / github.com/coder/code-server / getRoot

Function getRoot

src/node/routes/login.ts:28–53  ·  view source on GitHub ↗
(req: Request, error?: Error)

Source from the content-addressed store, hash-verified

26}
27
28const getRoot = async (req: Request, error?: Error): Promise<string> => {
29 const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
30 const locale = req.args["locale"] || "en"
31 i18n.changeLanguage(locale)
32 const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: req.args["app-name"] }) as string)
33
34 // Determine password message using i18n
35 let passwordMsg = i18n.t("LOGIN_PASSWORD")
36 if (req.args.usingEnvPassword) {
37 passwordMsg = i18n.t("LOGIN_USING_ENV_PASSWORD")
38 } else if (req.args.usingEnvHashedPassword) {
39 passwordMsg = i18n.t("LOGIN_USING_HASHED_PASSWORD")
40 }
41
42 return replaceTemplates(
43 req,
44 content
45 .replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: req.args["app-name"] }))
46 .replace(/{{WELCOME_TEXT}}/g, welcomeText)
47 .replace(/{{PASSWORD_MSG}}/g, passwordMsg)
48 .replace(/{{I18N_LOGIN_BELOW}}/g, i18n.t("LOGIN_BELOW"))
49 .replace(/{{I18N_PASSWORD_PLACEHOLDER}}/g, i18n.t("PASSWORD_PLACEHOLDER"))
50 .replace(/{{I18N_SUBMIT}}/g, i18n.t("SUBMIT"))
51 .replace(/{{ERROR}}/, error ? `<div class="error">${escapeHtml(error.message)}</div>` : ""),
52 )
53}
54
55const limiter = new RateLimiter()
56

Callers 1

login.tsFile · 0.85

Calls 2

replaceTemplatesFunction · 0.90
escapeHtmlFunction · 0.90

Tested by

no test coverage detected