Skip to main content

tuwunel_api/oidc/device/
entry.rs

1use const_str::format as const_format;
2use tuwunel_core::utils::html::escape as html_escape;
3
4use super::DEVICE_HEAD;
5
6pub(super) fn entry_html(error: Option<&str>) -> String {
7	let error_block = error
8		.map(|message| format!(r#"<p class="err">{}</p>"#, html_escape(message)))
9		.unwrap_or_default();
10
11	PAGE_HTML.replace("{error_block}", &error_block)
12}
13
14static PAGE_HTML: &str = const_format!(
15	r#"
16<!DOCTYPE html>
17<html lang="en">
18	<head>
19		{DEVICE_HEAD}
20		<title>Device sign-in</title>
21	</head>
22	<body>
23		<h1>Device sign-in</h1>
24		{{error_block}}
25		<form method="GET" action="/_tuwunel/oidc/device">
26			<label for="user_code">Enter the code shown on your device</label>
27			<input id="user_code" name="user_code" autocomplete="off"
28				autocapitalize="characters" spellcheck="false" required>
29			<button type="submit" class="primary">Continue</button>
30		</form>
31	</body>
32</html>"#
33);