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> {
|
||||
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())
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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})))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue