minor tweaks

This commit is contained in:
Hamcha 2023-06-29 16:42:57 +02:00
parent afc3ffd89f
commit 4bdb810e19
Signed by: hamcha
GPG key ID: 1669C533B8CF6D89
3 changed files with 11 additions and 16 deletions

View file

@ -18,7 +18,7 @@ pub fn hash(plaintext: &String) -> Result<String> {
}
pub fn verify(plaintext: &String, hash: &String) -> Result<bool> {
let parsed_hash = PasswordHash::new(&hash).map_err(|err| anyhow!(err))?;
let parsed_hash = PasswordHash::new(hash).map_err(|err| anyhow!(err))?;
Ok(Argon2::default()
.verify_password(plaintext.as_bytes(), &parsed_hash)
.is_ok())

View file

@ -59,9 +59,6 @@ async fn main() -> Result<()> {
let addr: SocketAddr = config.bind.parse()?;
tracing::debug!("listening on {}", addr);
Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
Server::bind(&addr).serve(app.into_make_service()).await?;
Ok(())
}

View file

@ -19,14 +19,14 @@ pub async fn bootstrap(State(state): State<Arc<AppState>>) -> Result<Json<Value>
.fetch_one(&state.database)
.await?;
match empty {
false => Err(AppError::ClientError {
if empty {
return Err(AppError::ClientError {
status: StatusCode::BAD_REQUEST,
code: "already-setup".to_string(),
message: "The instance was already bootstrapped".to_string(),
}),
true => {
//todo add user
});
}
let username = "admin";
let password = random();
@ -42,5 +42,3 @@ pub async fn bootstrap(State(state): State<Arc<AppState>>) -> Result<Json<Value>
Ok(Json(json!({"username": username, "password": password})))
}
}
}