Switch to git dep so build system will work
Some checks failed
Cargo Build & Test / Rust project - latest (stable) (push) Failing after 22s

This commit is contained in:
2026-07-02 21:59:01 -05:00
parent dd11f0a224
commit 59058207f4
6 changed files with 46 additions and 15 deletions

View File

@@ -115,12 +115,13 @@ impl<'r> FromRequest<'r> for InitialSetup {
.await
.map_error(|_| InitialSetupError::InternalError)
);
let user_count = try_outcome!(
sqlx::query!("SELECT count(name) as count from users")
.fetch_one(&mut **db)
.await
.into()
);
let user_count = match sqlx::query!("SELECT count(name) as count from users")
.fetch_one(&mut **db)
.await
{
Ok(v) => v,
Err(e) => return Outcome::Error(e.into()),
};
if user_count.count == 0 {
Outcome::Success(Self)
} else {

View File

@@ -4,7 +4,7 @@ use argon2::{Argon2, PasswordVerifier};
use base64::{DecodeError, Engine, alphabet::STANDARD, engine::GeneralPurposeConfig};
use password_hash::{PasswordHash, PasswordHasher, SaltString, rand_core::OsRng};
use rocket::{
async_trait, catch, catchers, form::Form, http::{CookieJar, Status}, post, request::{FromRequest, Outcome}, response::Redirect, routes, serde::{Deserialize, Serialize}, trace::debug, uri, Catcher, FromForm, Request, Route, TypedError
async_trait, catch, catchers, form::Form, http::{CookieJar, Status}, post, request::{FromRequest, Outcome}, response::{content::RawHtml, Redirect}, routes, serde::{Deserialize, Serialize}, trace::debug, uri, Catcher, FromForm, Request, Route, TypedError
};
use rocket_db_pools::Connection;
use rocket_dyn_templates::{context, Template};
@@ -15,6 +15,7 @@ pub struct BasicAuth {
username: String,
is_admin: bool,
}
#[derive(Debug, TypedError)]
pub enum Unauthorized {
#[error(status = 401)]
@@ -172,17 +173,17 @@ pub async fn update_password(
auth: BasicAuth,
pw: Form<PasswordChange<'_>>,
mut db: Connection<Db>,
) -> Result<&'static str, SqlError> {
) -> Result<Template, SqlError> {
let salt = SaltString::generate(&mut OsRng);
let pw_hash = Argon2::default()
.hash_password(pw.password.as_bytes(), salt.as_salt())
.expect("Failed to hash password");
sqlx::query("INSERT INTO users (name, password) VALUES (?1, ?2) ON CONFLICT DO UPDATE SET password = ?2")
sqlx::query("UPDATE users SET password = ?2 WHERE name = ?1")
.bind(auth.username)
.bind(pw_hash.to_string())
.execute(&mut **db)
.await?;
Ok("")
Ok(Template::render("password_updated", context!{}))
}
#[derive(Debug, Serialize, Deserialize, FromForm)]

View File

@@ -6,9 +6,9 @@ use crate::{
directory::{Episode, Podcast},
};
use rocket::{
Route, TypedError, get, post, routes,
Route, get, post, routes,
serde::{Deserialize, Serialize, json::Json},
trace::{debug, info},
trace::{debug},
};
use rocket_db_pools::{
Connection,