OpenAuth_server/src/views/authorize.ts

35 lines
888 B
TypeScript
Raw Normal View History

2020-08-07 14:16:39 +00:00
import { compile, TemplateDelegate } from "handlebars";
2019-12-16 13:02:51 +00:00
import { readFileSync } from "fs";
2020-08-07 14:16:39 +00:00
import { __ as i__ } from "i18n";
2019-12-16 13:02:51 +00:00
import config from "../config";
let template: TemplateDelegate<any>;
function loadStatic() {
let html = readFileSync("./views/out/authorize/authorize.html").toString();
2020-08-07 14:16:39 +00:00
template = compile(html);
2019-12-16 13:02:51 +00:00
}
2020-08-07 14:16:39 +00:00
export default function GetAuthPage(
__: typeof i__,
appname: string,
scopes: { name: string; description: string; logo: string }[]
): string {
2019-12-16 13:02:51 +00:00
if (config.core.dev) {
2020-08-07 14:16:39 +00:00
loadStatic();
2019-12-16 13:02:51 +00:00
}
2020-08-07 14:16:39 +00:00
return template(
{
title: __("Authorize %s", appname),
information: __(
"By clicking on ALLOW, you allow this app to access the requested recources."
),
scopes: scopes,
// request: request
},
{ helpers: { i18n: __ } }
);
2019-12-16 13:02:51 +00:00
}
2020-08-07 14:16:39 +00:00
loadStatic();