arminius_server_client/
auth.rs1#![allow(
9 clippy::allow_attributes,
10 reason = "This source file contains enums which allow `clippy::missing_docs_in_private_items`. But an exception to this lint will mistakenly report that it's unfulfilled when used with expect, even though it is not."
11)]
12
13use arminius_lib_component::error::MatrixApiError;
14use axum::http::StatusCode;
15use ruma::{UserId, api::error::ErrorKind};
16
17#[allow(
18 missing_docs,
19 clippy::missing_docs_in_private_items,
20 reason = "TODO(#2003): This exception predates us enabling `clippy::allow_attributes_without_reason`, so we don't know why it was enabled"
21)]
22#[derive(thiserror::Error, Debug, MatrixApiError)]
23#[error("Tried to perform account action that you are not allowed to.")]
24#[matrix_api_error(status_code = StatusCode::FORBIDDEN, error_kind = ErrorKind::Forbidden)]
25pub struct AccountActionNotAuthorized;
26
27pub fn check_user_matches(
30 user1: &UserId,
31 user2: &UserId,
32) -> Result<(), AccountActionNotAuthorized> {
33 if user1 != user2 {
34 return Err(AccountActionNotAuthorized);
35 }
36 Ok(())
37}