mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-02 05:22:11 +00:00
revert moving password hashing
This commit is contained in:
parent
abb2efef19
commit
5d70a9fbe4
|
@ -1,7 +1,6 @@
|
|||
use crate::PerformCrud;
|
||||
use activitypub_federation::http_signatures::generate_actor_keypair;
|
||||
use actix_web::web::Data;
|
||||
use bcrypt::{hash, DEFAULT_COST};
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{LoginResponse, Register},
|
||||
|
@ -118,7 +117,7 @@ impl PerformCrud for Register {
|
|||
let local_user_form = LocalUserInsertForm::builder()
|
||||
.person_id(inserted_person.id)
|
||||
.email(data.email.as_deref().map(str::to_lowercase))
|
||||
.password_encrypted(hash(&data.password, DEFAULT_COST)?)
|
||||
.password_encrypted(data.password.to_string())
|
||||
.show_nsfw(Some(data.show_nsfw))
|
||||
.accepted_application(accepted_application)
|
||||
.build();
|
||||
|
|
|
@ -56,7 +56,7 @@ impl LocalUser {
|
|||
}
|
||||
|
||||
pub async fn is_email_taken(pool: &DbPool, email_: &str) -> Result<bool, Error> {
|
||||
use diesel::dsl::*;
|
||||
use diesel::dsl::{exists, select};
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
select(exists(local_user.filter(email.eq(email_))))
|
||||
.get_result(conn)
|
||||
|
@ -81,9 +81,13 @@ impl Crud for LocalUser {
|
|||
}
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut form_with_encrypted_password = form.clone();
|
||||
let password_hash =
|
||||
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
||||
form_with_encrypted_password.password_encrypted = password_hash;
|
||||
|
||||
let local_user_ = insert_into(local_user)
|
||||
.values(form)
|
||||
.values(form_with_encrypted_password)
|
||||
.get_result::<Self>(conn)
|
||||
.await?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue