From: Dessalines Date: Sat, 18 Jan 2020 01:34:16 +0000 (-0500) Subject: Fixing error when email already exists. Fixes #427 X-Git-Url: http://these/git/%22https:/image.com/static/sneer-club-logo.svg?a=commitdiff_plain;h=8604c1d257ed68527ce345e6886eabfa929cbc87;p=lemmy.git Fixing error when email already exists. Fixes #427 --- diff --git a/README.md b/README.md index f216833c..f9daa66c 100644 --- a/README.md +++ b/README.md @@ -151,15 +151,15 @@ If you'd like to add translations, take a look a look at the [English translatio lang | done | missing --- | --- | --- -de | 95% | avatar,upload_avatar,show_avatars,docs,old_password,send_notifications_to_email,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw -eo | 82% | number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,theme,are_you_sure,yes,no -es | 90% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw -fr | 90% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw -it | 91% | avatar,upload_avatar,show_avatars,archive_link,docs,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw -nl | 100% | -ru | 78% | cross_posts,cross_post,number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,recent_comments,theme,monero,by,to,transfer_community,transfer_site,are_you_sure,yes,no -sv | 90% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw -zh | 76% | cross_posts,cross_post,users,number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,settings,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,recent_comments,nsfw,show_nsfw,theme,monero,by,to,transfer_community,transfer_site,are_you_sure,yes,no +de | 94% | avatar,upload_avatar,show_avatars,docs,old_password,send_notifications_to_email,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,email_already_exists +eo | 81% | number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,theme,are_you_sure,yes,no,email_already_exists +es | 89% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,email_already_exists +fr | 89% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,email_already_exists +it | 90% | avatar,upload_avatar,show_avatars,archive_link,docs,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,email_already_exists +nl | 100% | email_already_exists +ru | 77% | cross_posts,cross_post,number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,recent_comments,theme,monero,by,to,transfer_community,transfer_site,are_you_sure,yes,no,email_already_exists +sv | 89% | avatar,upload_avatar,show_avatars,archive_link,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,email_already_exists +zh | 75% | cross_posts,cross_post,users,number_of_communities,preview,upload_image,avatar,upload_avatar,show_avatars,formatting_help,view_source,sticky,unsticky,archive_link,settings,stickied,delete_account,delete_account_confirm,banned,creator,number_online,docs,replies,mentions,old_password,forgot_password,reset_password_mail_sent,password_change,new_password,no_email_setup,send_notifications_to_email,language,browser_default,downvotes_disabled,enable_downvotes,open_registration,registration_closed,enable_nsfw,recent_comments,nsfw,show_nsfw,theme,monero,by,to,transfer_community,transfer_site,are_you_sure,yes,no,email_already_exists If you'd like to update this report, run: diff --git a/docker/lemmy.hjson b/docker/lemmy.hjson index 2ec00de5..fce4470c 100644 --- a/docker/lemmy.hjson +++ b/docker/lemmy.hjson @@ -14,7 +14,7 @@ pool_size: 5 } # the domain name of your instance (eg "dev.lemmy.ml") - hostname: "rrr" + hostname: "my_domain" # address where lemmy should listen for incoming requests bind: "0.0.0.0" # port where lemmy should listen for incoming requests diff --git a/server/config/defaults.hjson b/server/config/defaults.hjson index 0fabda0b..9a7ad49d 100644 --- a/server/config/defaults.hjson +++ b/server/config/defaults.hjson @@ -15,7 +15,7 @@ pool_size: 5 } # the domain name of your instance (eg "dev.lemmy.ml") - hostname: "rrr" + hostname: "my_domain" # address where lemmy should listen for incoming requests bind: "0.0.0.0" # port where lemmy should listen for incoming requests diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 20eb09c1..ac700aca 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -239,7 +239,17 @@ impl Perform for Oper { // Create the user let inserted_user = match User_::register(&conn, &user_form) { Ok(user) => user, - Err(_e) => return Err(APIError::err(&self.op, "user_already_exists").into()), + Err(e) => { + let err_type = if e.to_string() + == "duplicate key value violates unique constraint \"user__email_key\"" + { + "email_already_exists" + } else { + "user_already_exists" + }; + + return Err(APIError::err(&self.op, err_type).into()); + } }; // Create the main community if it doesn't exist @@ -364,7 +374,17 @@ impl Perform for Oper { let updated_user = match User_::update(&conn, user_id, &user_form) { Ok(user) => user, - Err(_e) => return Err(APIError::err(&self.op, "couldnt_update_user").into()), + Err(e) => { + let err_type = if e.to_string() + == "duplicate key value violates unique constraint \"user__email_key\"" + { + "email_already_exists" + } else { + "user_already_exists" + }; + + return Err(APIError::err(&self.op, err_type).into()); + } }; // Return the jwt diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index f2184024..d919e509 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -210,6 +210,7 @@ export const en = { passwords_dont_match: 'Passwords do not match.', admin_already_created: "Sorry, there's already an admin.", user_already_exists: 'User already exists.', + email_already_exists: 'Email already exists.', couldnt_update_user: "Couldn't update user.", system_err_login: 'System error. Try logging out and back in.', },