minor tweaks
This commit is contained in:
parent
afc3ffd89f
commit
4bdb810e19
3 changed files with 11 additions and 16 deletions
|
@ -18,7 +18,7 @@ pub fn hash(plaintext: &String) -> Result<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn verify(plaintext: &String, hash: &String) -> Result<bool> {
|
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()
|
Ok(Argon2::default()
|
||||||
.verify_password(plaintext.as_bytes(), &parsed_hash)
|
.verify_password(plaintext.as_bytes(), &parsed_hash)
|
||||||
.is_ok())
|
.is_ok())
|
||||||
|
|
|
@ -59,9 +59,6 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let addr: SocketAddr = config.bind.parse()?;
|
let addr: SocketAddr = config.bind.parse()?;
|
||||||
tracing::debug!("listening on {}", addr);
|
tracing::debug!("listening on {}", addr);
|
||||||
Server::bind(&addr)
|
Server::bind(&addr).serve(app.into_make_service()).await?;
|
||||||
.serve(app.into_make_service())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@ pub async fn bootstrap(State(state): State<Arc<AppState>>) -> Result<Json<Value>
|
||||||
.fetch_one(&state.database)
|
.fetch_one(&state.database)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match empty {
|
if empty {
|
||||||
false => Err(AppError::ClientError {
|
return Err(AppError::ClientError {
|
||||||
status: StatusCode::BAD_REQUEST,
|
status: StatusCode::BAD_REQUEST,
|
||||||
code: "already-setup".to_string(),
|
code: "already-setup".to_string(),
|
||||||
message: "The instance was already bootstrapped".to_string(),
|
message: "The instance was already bootstrapped".to_string(),
|
||||||
}),
|
});
|
||||||
true => {
|
}
|
||||||
//todo add user
|
|
||||||
let username = "admin";
|
let username = "admin";
|
||||||
let password = random();
|
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})))
|
Ok(Json(json!({"username": username, "password": password})))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue