style: rustfmt
This commit is contained in:
@@ -3,8 +3,8 @@ use domain::{
|
|||||||
DomainError, Song, SongRepositoryPort, SongSummary, SortField, SortOrder, StoredSong,
|
DomainError, Song, SongRepositoryPort, SongSummary, SortField, SortOrder, StoredSong,
|
||||||
song_preview_chords,
|
song_preview_chords,
|
||||||
};
|
};
|
||||||
use std::str::FromStr;
|
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
use std::str::FromStr;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::row::{SongRow, row_to_summary, sort_clause};
|
use crate::row::{SongRow, row_to_summary, sort_clause};
|
||||||
@@ -16,8 +16,8 @@ pub struct SqliteSongRepository {
|
|||||||
|
|
||||||
impl SqliteSongRepository {
|
impl SqliteSongRepository {
|
||||||
pub async fn new(database_url: &str) -> Result<Self, sqlx::Error> {
|
pub async fn new(database_url: &str) -> Result<Self, sqlx::Error> {
|
||||||
let opts = sqlx::sqlite::SqliteConnectOptions::from_str(database_url)?
|
let opts =
|
||||||
.create_if_missing(true);
|
sqlx::sqlite::SqliteConnectOptions::from_str(database_url)?.create_if_missing(true);
|
||||||
let pool = SqlitePool::connect_with(opts).await?;
|
let pool = SqlitePool::connect_with(opts).await?;
|
||||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||||
Ok(Self { pool })
|
Ok(Self { pool })
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ pub struct LoginResult {
|
|||||||
pub async fn execute(deps: &LoginDeps, cmd: LoginCommand) -> Result<LoginResult, DomainError> {
|
pub async fn execute(deps: &LoginDeps, cmd: LoginCommand) -> Result<LoginResult, DomainError> {
|
||||||
let email = Email::new(&cmd.email)?;
|
let email = Email::new(&cmd.email)?;
|
||||||
|
|
||||||
let user = deps
|
let user = deps.user_repo.find_by_email(&email).await?.ok_or_else(|| {
|
||||||
.user_repo
|
|
||||||
.find_by_email(&email)
|
|
||||||
.await?
|
|
||||||
.ok_or_else(|| {
|
|
||||||
tracing::warn!(email = cmd.email, "login attempt with unknown email");
|
tracing::warn!(email = cmd.email, "login attempt with unknown email");
|
||||||
DomainError::Unauthorized("invalid credentials".into())
|
DomainError::Unauthorized("invalid credentials".into())
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ use super::deps::RegisterDeps;
|
|||||||
pub async fn execute(deps: &RegisterDeps, cmd: RegisterCommand) -> Result<(), DomainError> {
|
pub async fn execute(deps: &RegisterDeps, cmd: RegisterCommand) -> Result<(), DomainError> {
|
||||||
if !deps.allow_registration {
|
if !deps.allow_registration {
|
||||||
tracing::warn!("registration attempt while disabled");
|
tracing::warn!("registration attempt while disabled");
|
||||||
return Err(DomainError::Unauthorized(
|
return Err(DomainError::Unauthorized("registration is disabled".into()));
|
||||||
"registration is disabled".into(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let password = Password::new(&cmd.password)?;
|
let password = Password::new(&cmd.password)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user