(
Extension(session): Extension<LoggedInSession>,
State(state): State<AppState>,
Json(payload): Json<DelSessionPayload>,
)
| 83 | } |
| 84 | |
| 85 | pub 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 | |
| 115 | pub async fn del_all_sessions( |
| 116 | Extension(session): Extension<LoggedInSession>, |
nothing calls this directly
no test coverage detected