MCPcopy Create free account
hub / github.com/Botloader/botloader / del_session

Function del_session

components/webapi/src/routes/sessions.rs:85–113  ·  view source on GitHub ↗
(
    Extension(session): Extension<LoggedInSession>,
    State(state): State<AppState>,
    Json(payload): Json<DelSessionPayload>,
)

Source from the content-addressed store, hash-verified

83}
84
85pub async fn del_session(
86 Extension(session): Extension<LoggedInSession>,
87 State(state): State<AppState>,
88 Json(payload): Json<DelSessionPayload>,
89) -> ApiResult<impl IntoResponse> {
90 let deleting = state.db.get_session(&payload.token).await.map_err(|err| {
91 error!(%err, "failed fetching session");
92 ApiErrorResponse::InternalError
93 })?;
94
95 // TODO: return proper error
96 match deleting {
97 Some(s) => {
98 if s.user.id != session.session.user.id {
99 return Err(ApiErrorResponse::InternalError);
100 }
101 }
102 None => {
103 return Err(ApiErrorResponse::InternalError);
104 }
105 }
106
107 state.db.del_session(&payload.token).await.map_err(|err| {
108 error!(%err, "failed deleting session");
109 ApiErrorResponse::InternalError
110 })?;
111
112 Ok(EmptyResponse)
113}
114
115pub async fn del_all_sessions(
116 Extension(session): Extension<LoggedInSession>,

Callers

nothing calls this directly

Calls 2

get_sessionMethod · 0.80
del_sessionMethod · 0.80

Tested by

no test coverage detected