Add success error catching redirect

rust
Elnu 1 year ago
parent 5ef44a787e
commit 06b032cabf

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

Loading…
Cancel
Save