WIP
This commit is contained in:
parent
5ce50b76f5
commit
66ef5dc543
2 changed files with 18 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
use maud::{PreEscaped, html};
|
||||
use maud::PreEscaped;
|
||||
|
||||
use super::User;
|
||||
use crate::get_pg;
|
||||
use crate::{get_pg, ui::prelude::script};
|
||||
use std::str::FromStr;
|
||||
|
||||
pub trait CSRF {
|
||||
|
@ -15,7 +15,10 @@ impl CSRF for User {
|
|||
///
|
||||
/// This is useful for htmx requests to update the CSRF token in place.
|
||||
async fn update_csrf(&self) -> PreEscaped<String> {
|
||||
html! { script { (PreEscaped(format!("document.querySelectorAll('.csrf').forEach(element => {{ element.value = '{}'; }});", self.get_csrf().await))) }; }
|
||||
script(&format!(
|
||||
"document.querySelectorAll('.csrf').forEach(element => {{ element.value = '{}'; }});",
|
||||
self.get_csrf().await
|
||||
))
|
||||
}
|
||||
|
||||
/// Get CSRF Token for the current session
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue