dependencies update #11
@@ -4,24 +4,24 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.48.0", features = ["full"] }
|
||||
sea-orm = { version = "1.0", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
|
||||
sea-orm-migration = { version = "1.0", default-features = false, features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
tokio = { version = "1.49.0", features = ["full"] }
|
||||
sea-orm = { version = "1.1.19", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
|
||||
sea-orm-migration = { version = "1.1.19", default-features = false, features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
dotenvy = "0.15.7"
|
||||
axum = { version = "0.7", features = ["json"] }
|
||||
tower-http = { version = "0.5", features = ["cors"] }
|
||||
axum = { version = "0.8.8", features = ["json"] }
|
||||
tower-http = { version = "0.6.8", features = ["cors"] }
|
||||
chrono = { version = "0.4.42", features = ["serde"] }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
utoipa = { version = "5.4.0", features = ["axum_extras", "chrono", "decimal_float"] }
|
||||
utoipa-swagger-ui = { version = "8.0", features = ["axum"] }
|
||||
axum-login = "0.15"
|
||||
tower-sessions = "0.12"
|
||||
tower-sessions-sqlx-store = { version = "0.12", features = ["postgres"] }
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
axum-login = "0.18.0"
|
||||
tower-sessions = "0.14.0"
|
||||
tower-sessions-sqlx-store = { version = "0.15.0", features = ["postgres"] }
|
||||
argon2 = "0.5"
|
||||
async-trait = "0.1"
|
||||
thiserror = "2.0"
|
||||
time = "0.3"
|
||||
oauth2 = { version = "5.0.0", features = ["reqwest"] }
|
||||
reqwest = { version = "0.12.28", features = ["json"] }
|
||||
rand = "0.8"
|
||||
reqwest = { version = "0.13.1", features = ["json"] }
|
||||
rand = "0.9.2"
|
||||
@@ -40,19 +40,20 @@ pub struct Credentials {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl AuthnBackend for AuthBackend {
|
||||
type User = user::Model;
|
||||
type Credentials = Credentials;
|
||||
type Error = Error;
|
||||
|
||||
async fn authenticate(
|
||||
fn authenticate(
|
||||
&self,
|
||||
creds: Self::Credentials,
|
||||
) -> Result<Option<Self::User>, Self::Error> {
|
||||
) -> impl Future<Output = Result<Option<Self::User>, Self::Error>> + Send {
|
||||
let db = self.db.clone();
|
||||
async move {
|
||||
let user = User::find()
|
||||
.filter(user::Column::Username.eq(&creds.username))
|
||||
.one(&self.db)
|
||||
.one(&db)
|
||||
.await?;
|
||||
|
||||
if let Some(user) = user {
|
||||
@@ -73,12 +74,20 @@ impl AuthnBackend for AuthBackend {
|
||||
Err(Error::InvalidCredentials)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_user(&self, user_id: &UserId<Self>) -> Result<Option<Self::User>, Self::Error> {
|
||||
let user = User::find_by_id(*user_id).one(&self.db).await?;
|
||||
fn get_user(
|
||||
&self,
|
||||
user_id: &UserId<Self>,
|
||||
) -> impl Future<Output = Result<Option<Self::User>, Self::Error>> + Send {
|
||||
let db = self.db.clone();
|
||||
let user_id = *user_id;
|
||||
async move {
|
||||
let user = User::find_by_id(user_id).one(&db).await?;
|
||||
Ok(user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash_password(password: &str) -> Result<String, Error> {
|
||||
let salt = SaltString::generate(&mut OsRng);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sea_orm::*;
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::distr::Alphanumeric;
|
||||
use rand::Rng;
|
||||
use crate::models::invite_link::{self, Entity as InviteLink, Model as InviteLinkModel};
|
||||
use crate::models::{user, User};
|
||||
@@ -8,7 +8,7 @@ pub struct InviteLinkService;
|
||||
|
||||
impl InviteLinkService {
|
||||
pub fn generate_token() -> String {
|
||||
rand::thread_rng()
|
||||
rand::rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(32)
|
||||
.map(char::from)
|
||||
|
||||
Reference in New Issue
Block a user