fix errors, move password hashing into User add sqlx offline checks
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -33,8 +33,8 @@ pub fn routes() -> axum::Router {
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
async fn get_login() -> Json<Flows> {
|
||||
Json(Flows::new())
|
||||
async fn get_login() -> Result<Json<Flows>, ApiError> {
|
||||
Ok(Json(Flows::new()))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
@ -81,18 +81,12 @@ async fn post_register(
|
||||
.then(|| ())
|
||||
.ok_or(RegistrationError::UserIdTaken)?;
|
||||
|
||||
let salt = SaltString::generate(OsRng);
|
||||
let argon2 = Argon2::default();
|
||||
let pw_hash = argon2
|
||||
.hash_password(auth_data.password().as_bytes(), &salt)?
|
||||
.to_string();
|
||||
|
||||
let display_name = match body.initial_device_display_name() {
|
||||
Some(display_name) => display_name.as_ref(),
|
||||
None => "Random displayname",
|
||||
};
|
||||
|
||||
let user = User::create(&db, &user_id, &user_id.to_string(), &pw_hash).await?;
|
||||
let user = User::create(&db, &user_id, &user_id.to_string(), auth_data.password()).await?;
|
||||
let device = Device::create(&db, &user, "test", display_name).await?;
|
||||
|
||||
(user, device)
|
||||
|
@ -45,7 +45,7 @@ pub enum ApiError {
|
||||
DBError(#[from] sqlx::Error),
|
||||
|
||||
#[error("Generic Error")]
|
||||
Generic(anyhow::Error),
|
||||
Generic(anyhow::Error)
|
||||
}
|
||||
|
||||
impl From<anyhow::Error> for ApiError {
|
||||
|
Reference in New Issue
Block a user