Add success error catching redirect

This commit is contained in:
Elnu 2023-06-16 17:21:40 -07:00
parent 5ef44a787e
commit 06b032cabf

View file

@ -99,6 +99,7 @@ async fn post_login(login: Form<Login<'_>>, cookies: &CookieJar<'_>) -> Redirect
fn success() -> RawHtml<&'static str> {
RawHtml("<form action=\"/login\" method=\"post\"></form>
<script>
try {
const params = new URLSearchParams(location.hash.slice(1));
const form = document.querySelector(\"form\");
[\"token_type\", \"access_token\", \"expires_in\", \"scope\"].forEach(field => {
@ -109,6 +110,9 @@ fn success() -> RawHtml<&'static str> {
form.appendChild(input);
});
form.submit();
} catch {
location.href = \"/\";
}
</script>")
}