mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
fix: fix the issues caused by authifier migration
Signed-off-by: İspik <ispik@ispik.dev>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -7330,6 +7330,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha1 0.10.6",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"totp-lite",
|
||||
"ulid",
|
||||
"unicode-segmentation",
|
||||
|
||||
@@ -28,6 +28,7 @@ futures-locks = "0.7.1"
|
||||
async-lock = "2.8.0"
|
||||
async-recursion = "1.0.4"
|
||||
tokio-util = { version = "0.7.18" }
|
||||
tokio-stream = "0.1.18"
|
||||
|
||||
# Error Handling
|
||||
anyhow = "1.0.100"
|
||||
|
||||
@@ -82,6 +82,7 @@ async-recursion = { workspace = true }
|
||||
|
||||
# Async
|
||||
tokio = { workspace = true, optional = true }
|
||||
tokio-stream = { workspace = true }
|
||||
|
||||
# Axum Impl
|
||||
axum = { workspace = true, optional = true }
|
||||
|
||||
@@ -2,16 +2,6 @@
|
||||
mod mongodb;
|
||||
mod reference;
|
||||
|
||||
use authifier::config::Captcha;
|
||||
use authifier::config::EmailVerificationConfig;
|
||||
use authifier::config::PasswordScanning;
|
||||
use authifier::config::ResolveIp;
|
||||
use authifier::config::SMTPSettings;
|
||||
use authifier::config::Shield;
|
||||
use authifier::config::Template;
|
||||
use authifier::config::Templates;
|
||||
use authifier::config::EmailExpiryConfig;
|
||||
use authifier::Authifier;
|
||||
use rand::Rng;
|
||||
use revolt_config::config;
|
||||
use revolt_result::Result;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use async_std::stream::StreamExt;
|
||||
use tokio_stream::StreamExt;
|
||||
use revolt_result::Result;
|
||||
|
||||
use crate::AdminAuditItem;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use async_std::stream::StreamExt;
|
||||
use tokio_stream::StreamExt;
|
||||
use bson::Document;
|
||||
use revolt_result::Result;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use revolt_config::{capture_internal_error, report_error};
|
||||
use revolt_result::Result;
|
||||
use revolt_result::{Error, Result};
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{AdminAuthorization, AdminMachineToken, AdminUser, Database};
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> FromRequest<'r> for AdminMachineToken {
|
||||
type Error = authifier::Error;
|
||||
type Error = Error;
|
||||
|
||||
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||
let user: &Option<AdminMachineToken> = request
|
||||
@@ -48,14 +48,14 @@ impl<'r> FromRequest<'r> for AdminMachineToken {
|
||||
if let Some(user) = user {
|
||||
Outcome::Success(user.clone())
|
||||
} else {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::InvalidSession))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(InvalidSession)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> FromRequest<'r> for AdminAuthorization {
|
||||
type Error = authifier::Error;
|
||||
type Error = Error;
|
||||
|
||||
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||
let machine: &Option<AdminMachineToken> = request
|
||||
@@ -94,7 +94,7 @@ impl<'r> FromRequest<'r> for AdminAuthorization {
|
||||
|
||||
if let Some(machine) = machine {
|
||||
if !machine.on_behalf_of.active {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::LockedOut))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(LockedOut)))
|
||||
} else {
|
||||
Outcome::Success(AdminAuthorization::AdminMachine(machine.clone()))
|
||||
}
|
||||
@@ -134,12 +134,12 @@ impl<'r> FromRequest<'r> for AdminAuthorization {
|
||||
|
||||
if let Some(user) = user {
|
||||
if !user.active {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::LockedOut))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(LockedOut)))
|
||||
} else {
|
||||
Outcome::Success(AdminAuthorization::AdminUser(user.clone()))
|
||||
}
|
||||
} else {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::InvalidCredentials))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(InvalidSession)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
|
||||
use revolt_result::Error;
|
||||
use crate::{AdminUser, Database};
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> FromRequest<'r> for AdminUser {
|
||||
type Error = authifier::Error;
|
||||
type Error = Error;
|
||||
|
||||
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||
let user: &Option<AdminUser> = request
|
||||
@@ -32,12 +32,12 @@ impl<'r> FromRequest<'r> for AdminUser {
|
||||
|
||||
if let Some(user) = user {
|
||||
if !user.active {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::LockedOut))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(LockedOut)))
|
||||
} else {
|
||||
Outcome::Success(user.clone())
|
||||
}
|
||||
} else {
|
||||
Outcome::Error((Status::Unauthorized, authifier::Error::InvalidCredentials))
|
||||
Outcome::Error((Status::Unauthorized, create_error!(InvalidCredentials)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,10 @@ pub async fn admin_account_delete(
|
||||
}
|
||||
}
|
||||
|
||||
db.delete_authifier_account(&target.id).await?;
|
||||
db.fetch_account(&target.id)
|
||||
.await?
|
||||
.mark_deleted(db)
|
||||
.await?;
|
||||
|
||||
create_audit_action(
|
||||
db,
|
||||
|
||||
@@ -39,7 +39,9 @@ pub async fn admin_account_disable(
|
||||
}
|
||||
}
|
||||
|
||||
db.disable_authifier_account(&target.id).await?;
|
||||
db.fetch_account(&target.id).await?
|
||||
.disable(db)
|
||||
.await?;
|
||||
|
||||
create_audit_action(
|
||||
db,
|
||||
|
||||
@@ -190,5 +190,5 @@ pub async fn edit_data(
|
||||
.update(db, partial, remove.into_iter().map(Into::into).collect())
|
||||
.await?;
|
||||
|
||||
Ok(Json(server.into()))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user