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
show a form error when the user name or email has an illegal character #423
Conversation
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.
Thanks! Can you additionally add a unit test to cover this change?
registration/views.py
Outdated
try: | ||
new_user = self.register(form) | ||
except OperationalError: | ||
form.add_error(None, _("invalid characters destected in name or 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.
form.add_error(None, _("invalid characters destected in name or email")) | |
form.add_error(None, _("invalid characters detected in name or email")) |
registration/views.py
Outdated
from django.shortcuts import redirect | ||
from django.utils.decorators import method_decorator | ||
from django.utils.module_loading import import_string | ||
from django.utils.translation import ugettext_lazy as _ |
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.
ugettext_lazy
is deprecated, use gettext_laxy
@JeremyMordkoff can you rebase this branch to pickup the CI fixes I added in #432? |
Yes, and I have another fix for running tests that use atomic transactions
and need mail.Outbox
I've been using git for a few years but almost exclusively in a corporate
environment so if I screw up, feel free to criticize
…On Sun, Feb 5, 2023, 4:55 PM Joshua Blum ***@***.***> wrote:
@JeremyMordkoff <https://github.com/JeremyMordkoff> can you rebase this
branch to pickup the CI fixes I added in #432
<#432>?
—
Reply to this email directly, view it on GitHub
<#423 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY3RWMYQLJUMVDZLTAPBYTWWAOWFANCNFSM5TL7HG6Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
These changes are a mess. Let me try to untangle them
First, I am getting a failure in my unit tests when I try to use
mail.outbox. I see it works for you, but for some reason it does not work
for me. I don't know why.
Second, my fix for bad characters was actually triggered by bad characters
in the cell-phone field (I am using a custom registration form) so I think
I am better off using a better field validator instead.
Bottom line ... I wouldn't wait for my changes. They will probably turn
out to be nothing.
…On Sun, May 8, 2022 at 9:19 PM Joshua Blum ***@***.***> wrote:
***@***.**** commented on this pull request.
Thanks! Can you additionally add a unit test to cover this change?
------------------------------
In registration/views.py
<#423 (comment)>
:
> @@ -53,7 +55,11 @@ def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
def form_valid(self, form):
- new_user = self.register(form)
+ try:
+ new_user = self.register(form)
+ except OperationalError:
+ form.add_error(None, _("invalid characters destected in name or email"))
⬇️ Suggested change
- form.add_error(None, _("invalid characters destected in name or email"))
+ form.add_error(None, _("invalid characters detected in name or email"))
—
Reply to this email directly, view it on GitHub
<#423 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY3RWM7X37IU4PTZX2V2WLVJBR2VANCNFSM5TL7HG6Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Jeremy Mordkoff
"Darkness cannot drive out darkness, only light can do that. Hate cannot
drive out hate, only love can do that." —Martin Luther King Jr., *Strength
to Love*, 1963
*"some dance to remember, some dance to forget"* -- Eagles, *Hotel
California*
|
@jmordkoff no problem, thanks for opening a PR. I'm going to close this for now, if you have a general fix you'd like to add, feel free to open another PR in the future. |
Hi, forgive me if I'm not following the process. I'm new to github. This small change avoids a server hiccup is a user's name or email contains an illegal character (according to your DB).