-
-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct error messages if user registers with taken user/email #3093
Conversation
71c5bf1
to
01a352a
Compare
crates/api_crud/src/user/create.rs
Outdated
@@ -111,28 +118,12 @@ 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(data.password.to_string()) | |||
.password_encrypted(hash(&data.password, DEFAULT_COST)?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to move this up, but I hope you tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasnt working after all, because it also needs to hash the setup password defined in config file. Reverted the change.
pub async fn is_email_taken(pool: &DbPool, email_: &str) -> Result<bool, Error> { | ||
let conn = &mut get_conn(pool).await?; | ||
let count = local_user | ||
.filter(email.eq(email_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use exists: https://docs.diesel.rs/master/diesel/dsl/fn.exists.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
71a3824
to
a1ce1f2
Compare
397f1b3
to
5f9c7af
Compare
5f9c7af
to
5d70a9f
Compare
Fixes #2955