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

6
Cargo.lock generated
View File

@@ -2272,6 +2272,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket" name = "rocket"
version = "0.6.0-dev" version = "0.6.0-dev"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
@@ -2321,6 +2322,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket_codegen" name = "rocket_codegen"
version = "0.6.0-dev" version = "0.6.0-dev"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"devise", "devise",
"glob", "glob",
@@ -2336,6 +2338,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket_db_pools" name = "rocket_db_pools"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"log", "log",
"rocket", "rocket",
@@ -2347,6 +2350,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket_db_pools_codegen" name = "rocket_db_pools_codegen"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"devise", "devise",
"quote", "quote",
@@ -2355,6 +2359,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket_dyn_templates" name = "rocket_dyn_templates"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"normpath", "normpath",
"notify", "notify",
@@ -2366,6 +2371,7 @@ dependencies = [
[[package]] [[package]]
name = "rocket_http" name = "rocket_http"
version = "0.6.0-dev" version = "0.6.0-dev"
source = "git+https://github.com/the10thWiz/Rocket.git?rev=ecceb93ba65d91dcf214000fa648d69cd74b95fb#ecceb93ba65d91dcf214000fa648d69cd74b95fb"
dependencies = [ dependencies = [
"cookie", "cookie",
"either", "either",

View File

@@ -6,12 +6,27 @@ edition = "2024"
[dependencies] [dependencies]
base64 = "0.22.1" base64 = "0.22.1"
chrono = { version = "0.4.41", features = ["serde"] } chrono = { version = "0.4.41", features = ["serde"] }
rocket = { path = "../rocket/core/lib", features = ["json", "tls", "secrets"] }
rocket_dyn_templates = { path = "../rocket/contrib/dyn_templates", features = ["tera"] }
rocket_db_pools = { path = "../rocket/contrib/db_pools/lib", features = ["sqlx_sqlite", "sqlx_macros"] }
sqlx = "*" sqlx = "*"
semver = { version = "1.0.26", features = ["serde"] } semver = { version = "1.0.26", features = ["serde"] }
password-hash = { version = "0.5.0", features = ["std"] } password-hash = { version = "0.5.0", features = ["std"] }
argon2 = { version = "0.5.3", features = ["std"] } argon2 = { version = "0.5.3", features = ["std"] }
lazy_static = "1.5.0" lazy_static = "1.5.0"
either = "1.15.0" either = "1.15.0"
[dependencies.rocket]
# path = "../rocket/core/lib"
git = "https://github.com/the10thWiz/Rocket.git"
rev = "ecceb93ba65d91dcf214000fa648d69cd74b95fb"
features = ["json", "tls", "secrets"]
[dependencies.rocket_dyn_templates]
# path = "../rocket/contrib/dyn_templates"
git = "https://github.com/the10thWiz/Rocket.git"
rev = "ecceb93ba65d91dcf214000fa648d69cd74b95fb"
features = ["tera"]
[dependencies.rocket_db_pools]
# path = "../rocket/contrib/db_pools/lib"
git = "https://github.com/the10thWiz/Rocket.git"
rev = "ecceb93ba65d91dcf214000fa648d69cd74b95fb"
features = ["sqlx_sqlite", "sqlx_macros"]

View File

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

View File

@@ -4,7 +4,7 @@ use argon2::{Argon2, PasswordVerifier};
use base64::{DecodeError, Engine, alphabet::STANDARD, engine::GeneralPurposeConfig}; use base64::{DecodeError, Engine, alphabet::STANDARD, engine::GeneralPurposeConfig};
use password_hash::{PasswordHash, PasswordHasher, SaltString, rand_core::OsRng}; use password_hash::{PasswordHash, PasswordHasher, SaltString, rand_core::OsRng};
use rocket::{ 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_db_pools::Connection;
use rocket_dyn_templates::{context, Template}; use rocket_dyn_templates::{context, Template};
@@ -15,6 +15,7 @@ pub struct BasicAuth {
username: String, username: String,
is_admin: bool, is_admin: bool,
} }
#[derive(Debug, TypedError)] #[derive(Debug, TypedError)]
pub enum Unauthorized { pub enum Unauthorized {
#[error(status = 401)] #[error(status = 401)]
@@ -172,17 +173,17 @@ pub async fn update_password(
auth: BasicAuth, auth: BasicAuth,
pw: Form<PasswordChange<'_>>, pw: Form<PasswordChange<'_>>,
mut db: Connection<Db>, mut db: Connection<Db>,
) -> Result<&'static str, SqlError> { ) -> Result<Template, SqlError> {
let salt = SaltString::generate(&mut OsRng); let salt = SaltString::generate(&mut OsRng);
let pw_hash = Argon2::default() let pw_hash = Argon2::default()
.hash_password(pw.password.as_bytes(), salt.as_salt()) .hash_password(pw.password.as_bytes(), salt.as_salt())
.expect("Failed to hash password"); .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(auth.username)
.bind(pw_hash.to_string()) .bind(pw_hash.to_string())
.execute(&mut **db) .execute(&mut **db)
.await?; .await?;
Ok("") Ok(Template::render("password_updated", context!{}))
} }
#[derive(Debug, Serialize, Deserialize, FromForm)] #[derive(Debug, Serialize, Deserialize, FromForm)]

View File

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

View File

@@ -0,0 +1,8 @@
{% extends "_layout" %}
{% block content %}
<div class="p-4">
<h4>Password successfully updated</h4>
<a href="/">Home</a>
</div>
{% endblock content %}