get paths from global settings, remove trailing id
This commit is contained in:
parent
6f5acffcb3
commit
d0f7feab9d
@ -160,26 +160,27 @@ struct ProgramItem {
|
||||
/// }
|
||||
/// ```
|
||||
#[post("/auth/login/")]
|
||||
pub async fn login(pool: web::Data<Pool<Sqlite>>, credentials: web::Json<User>) -> impl Responder {
|
||||
pub async fn login(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
credentials: web::Json<User>,
|
||||
) -> Result<impl Responder, ServiceError> {
|
||||
let username = credentials.username.clone();
|
||||
let password = credentials.password.clone();
|
||||
|
||||
match handles::select_login(&pool, &username).await {
|
||||
Ok(mut user) => {
|
||||
let role = handles::select_role(&pool, &user.role_id.unwrap_or_default())
|
||||
.await
|
||||
.unwrap_or(Role::Guest);
|
||||
let role = handles::select_role(&pool, &user.role_id.unwrap_or_default()).await?;
|
||||
|
||||
let pass = user.password.clone();
|
||||
let password_clone = password.clone();
|
||||
let pass_hash = user.password.clone();
|
||||
let cred_password = password.clone();
|
||||
|
||||
user.password = "".into();
|
||||
|
||||
let verified_password = web::block(move || {
|
||||
let hash = PasswordHash::new(&pass).unwrap();
|
||||
Argon2::default().verify_password(password_clone.as_bytes(), &hash)
|
||||
let hash = PasswordHash::new(&pass_hash)?;
|
||||
Argon2::default().verify_password(cred_password.as_bytes(), &hash)
|
||||
})
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
if verified_password.is_ok() {
|
||||
let claims = Claims::new(
|
||||
@ -195,31 +196,31 @@ pub async fn login(pool: web::Data<Pool<Sqlite>>, credentials: web::Json<User>)
|
||||
|
||||
info!("user {} login, with role: {role}", username);
|
||||
|
||||
web::Json(UserObj {
|
||||
Ok(web::Json(UserObj {
|
||||
message: "login correct!".into(),
|
||||
user: Some(user),
|
||||
})
|
||||
.customize()
|
||||
.with_status(StatusCode::OK)
|
||||
.with_status(StatusCode::OK))
|
||||
} else {
|
||||
error!("Wrong password for {username}!");
|
||||
|
||||
web::Json(UserObj {
|
||||
Ok(web::Json(UserObj {
|
||||
message: "Wrong password!".into(),
|
||||
user: None,
|
||||
})
|
||||
.customize()
|
||||
.with_status(StatusCode::FORBIDDEN)
|
||||
.with_status(StatusCode::FORBIDDEN))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Login {username} failed! {e}");
|
||||
web::Json(UserObj {
|
||||
Ok(web::Json(UserObj {
|
||||
message: format!("Login {username} failed!"),
|
||||
user: None,
|
||||
})
|
||||
.customize()
|
||||
.with_status(StatusCode::BAD_REQUEST)
|
||||
.with_status(StatusCode::BAD_REQUEST))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,15 +67,15 @@ pub async fn create_channel(
|
||||
channel.preview_url = preview_url(&channel.preview_url, channel.id);
|
||||
|
||||
if global.shared_storage {
|
||||
channel.hls_path = Path::new(&channel.hls_path)
|
||||
channel.hls_path = Path::new(&global.public_root)
|
||||
.join(channel.id.to_string())
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
channel.playlist_path = Path::new(&channel.playlist_path)
|
||||
channel.playlist_path = Path::new(&global.playlist_root)
|
||||
.join(channel.id.to_string())
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
channel.storage_path = Path::new(&channel.storage_path)
|
||||
channel.storage_path = Path::new(&global.storage_root)
|
||||
.join(channel.id.to_string())
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
2
frontend
2
frontend
@ -1 +1 @@
|
||||
Subproject commit fd85411c773f86cd3cef02fdd8c3fd041d9af1a8
|
||||
Subproject commit 0b1e083ce5b1818589b899d2fe0cc04f4100df32
|
Loading…
Reference in New Issue
Block a user