MCPcopy Create free account
hub / github.com/bitswired/rustgpt / auth

Function auth

src/middleware.rs:60–78  ·  view source on GitHub ↗
(
    Extension(current_user): Extension<Option<User>>,
    req: Request<B>,
    next: Next<B>,
)

Source from the content-addressed store, hash-verified

58}
59
60pub async fn auth<B>(
61 Extension(current_user): Extension<Option<User>>,
62 req: Request<B>,
63 next: Next<B>,
64) -> Response
65where
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
80pub async fn valid_openai_api_key<B>(
81 Extension(current_user): Extension<Option<User>>,

Callers

nothing calls this directly

Calls 2

error_responseFunction · 0.85
into_responseMethod · 0.45

Tested by

no test coverage detected