(
Extension(current_user): Extension<Option<User>>,
req: Request<B>,
next: Next<B>,
)
| 58 | } |
| 59 | |
| 60 | pub async fn auth<B>( |
| 61 | Extension(current_user): Extension<Option<User>>, |
| 62 | req: Request<B>, |
| 63 | next: Next<B>, |
| 64 | ) -> Response |
| 65 | where |
| 66 | B: Send + 'static, |
| 67 | { |
| 68 | let to = format!("/error?code={}&message={}", "401", "Log in"); |
| 69 | let r = Redirect::to(&to); |
| 70 | let mut r = r.into_response(); |
| 71 | let h = r.headers_mut(); |
| 72 | h.insert("HX-Redirect", HeaderValue::from_str(&to).unwrap()); |
| 73 | |
| 74 | match current_user { |
| 75 | Some(_user) => next.run(req).await, |
| 76 | _ => error_response(401, "You need to log in to view this page"), |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | pub async fn valid_openai_api_key<B>( |
| 81 | Extension(current_user): Extension<Option<User>>, |
nothing calls this directly
no test coverage detected