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

View File

@@ -6,12 +6,27 @@ edition = "2024"
[dependencies]
base64 = "0.22.1"
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 = "*"
semver = { version = "1.0.26", features = ["serde"] }
password-hash = { version = "0.5.0", features = ["std"] }
argon2 = { version = "0.5.3", features = ["std"] }
lazy_static = "1.5.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
.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,

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 %}