|
|
A two-step verification for new accounts by verifying email.
License: GNU General Public License v3.0
When using this it marks the user as active, but that is the page it goes to afterward.
\Python\Python311\Lib\site-packages\verify_email\views.py, line 58, in verify_user_and_activate
'link': reverse(login_page)
^^^^^^^^^^^^^^^^^^^
@foo290 Import in views is erroring out.
When attempting to resend a verification email for a user that does not exist it just shows a blank page with "User Not Found" in the top left corner.
I'm just requesting that a template is used instead of this simple error message. It would be nice to be able to use a custom template to display this message.
Hello, this is awesome package, you have saved me just right on time :) Thank you very much!
Everything is working properly so far, I am just seeing this message in the console:
verify_email.LinkCounter: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the VerifyEmailConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
It seems that adding default_auto_field = 'django.db.models.AutoField'
in apps.VerifyEmailConfig fix the warning, but anyway it may be something that you need to check out.
Thank you!
hello when i signup with a user the email of account activation is being sent to my inbox,but after i click it redirect me to the verification failed page saying that there is something with the link (from the first time click that happens).
Using django 4.0, running python manage.py makemigrations
generates a new migration for the verify_email
app.
Hey!
Thanks for the plugin, but I have some trouble make it working. The link is being generated seems to be None or Empty as in the Email its with a href="_blank"
. I tried to debug it but could not found any issues.
I am using "django-use-email-as-username", but it basically simply removes the user.name, but the rest is working the same. Checked your code and it does not look like you use the user.name, so there should be no issues.
And I currently run it on localhost (with using an external SMTP Server for Mails) for testing, could this make issues with the link generation?
I've installed the module as stated in your documentation however once I try to run the app it returns an error:
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'verify_email'
Change 'verify_email.apps.VerifyEmailConfig'
to 'verify_email'
also didn't resolve the issue
everything worked correctly but when the user hit the verify button in the massage an error happed says
NoReverseMatch at /verification/user/verify-email/bW9ydGF6YS5hbWVyMjBAZ21haWwuY29t/YnBkbTVmLTEyNWNlNWY5ZjZjMTgzYThhMTdlZTUxNTNiOGEyNDM4/
Reverse for '/accounts/login/' not found. '/accounts/login/' is not a valid view function or pattern name.
anyone can help me ?
Django-Verify-Email/verify_email/views.py
Line 132 in 5ba6f64
Is there any straightforward way to implement admin approval of users with this package?
Thanks for this great application. I was able to implement to Verifying User's email :. from the Advance downward the explanations do not have example on how to implement.
Any pointer to further detailed write up will be appreciated.
Thanks.
Hello when I signup with a new user - The new user receives a verify email - but when the [verify] link gets clicked it's response is a verification failed page : Invalid Link
This link is invalid or been used already, we cannot verify using this link.
http://127.0.0.1:8000/verification/user/verify-email/Ym9hcmRtZW1iZXJAdGllcnJhc2t5LmNvbQ==/YjN5MWRkLWEyMTJkMjY5YzE3OWI3YTgwOWEwMDI1M2E0YjA5NjUz/
This link seems to be missing the -useremail- in -path(f'user/verify-email/-useremail-/-usertoken-/'-
I'm not sure if my custom Member is the issue in regards to :email = models.EmailField(_('email address'), unique=True)
class Member(AbstractBaseUser, PermissionsMixin):
# INITIAL MEMBER BASIC INFORMATION (05) #
first_name = models.CharField(_('first name'), max_length=150, blank=True)
last_name = models.CharField(_('last name'), max_length=150, blank=True)
phone = models.CharField(_('phone'), max_length=150, blank=True)
email = models.EmailField(_('email address'), unique=True)
How to catch or check if sending email was successful in views?
Hello! Thanks so much for this simple and easy to use package!
I think I might be missing something in my Users model or maybe something else. I'm not sure what this means.
'Users' object has no attribute 'last_login'
I'm happy to provide any code to help troubleshoot this. Sorry I'm very new to python I appreciate any support you can provide me.
Thanks!
Traceback (most recent call last):
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\verify_email\email_handler.py", line 46, in send_verification_link
verification_url = self.token_manager.generate_link(request, inactive_user, useremail)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\verify_email\token_manager.py", line 200, in generate_link
token = self.__generate_token(inactive_user)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\verify_email\token_manager.py", line 149, in __generate_token
user_token = default_token_generator.make_token(user)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\tokens.py", line 28, in make_token
return self._make_token_with_timestamp(user, self._num_seconds(self._now()))
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\tokens.py", line 78, in _make_token_with_timestamp
self._make_hash_value(user, timestamp),
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\tokens.py", line 104, in _make_hash_value
login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None)
During handling of the above exception ('Users' object has no attribute 'last_login'), another exception occurred:
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\camst\OneDrive\Documents\GitHub\Newsletter\JW-Newsletter\website\app\views.py", line 13, in index
inactive_user = send_verification_email(request, form)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\verify_email\email_handler.py", line 83, in send_verification_email
return _VerifyEmail().send_verification_link(request, form)
File "C:\Users\camst\AppData\Local\Programs\Python\Python39\lib\site-packages\verify_email\email_handler.py", line 59, in send_verification_link
raise Exception(error)
Exception Type: Exception at /
Exception Value: 'Users' object has no attribute 'last_login'
Error code:
Error in sending email. Error code: 550 Error: b'not local sender over smtp'
Hello , I did everything step by step, but nothing comes out.
Hello Developers,
I am registering the user in my app using a custom html form submission, Is there any way to use this tool in my app so that I can use this one?
Thankyou.
Is this project still actively maintained?
In the __str__
method of LinkCounter
in models.py
, use get_username()
instead of username
to account for apps that have changed the USERNAME_FIELD
of their user model.
See this link for more info. Relevant code:
Django-Verify-Email/verify_email/models.py
Lines 11 to 12 in 5ba6f64
perhaps I have done something wrong with the update, but when upgrading a system existing users cant log in because they dont have a link counter associated with them.
perhaps the initial migration should include something which creates one for existing users?
RelatedObjectDoesNotExist at /accounts/login/
User has no linkcounter.
\verify_email\signals.py, line 14, in save_count
instance.linkcounter.save()
I'm trying to implement the re-sending of links, but the documentation doesn't make it clear how to do that. I had a read through the code and saw that it takes the email and the token but does not say how to get them and it doesnt look like they are saved after the first email is sent
what I hope I can do with this is have a form on my log in pages where a user can input their email address and have the email resent, is that possible?
RequestNewVerificationEmail
is a ModelForm
for the user model of an app. If the user model requires a unique email, then form.is_valid
will be False
. If this form is meant to create a new user (which I don't think it is?), then it should be robust enough to handle varied user models (e.g. what if a field besides email is required?). Otherwise, it probably shouldn't be a ModelForm
, just a normal form with an EmailField
Django documentation said about isActive as follows
Boolean. Designates whether this user account should be considered active.
We recommend that you set this flag to False instead of deleting accounts;
that way, if your applications have any foreign keys to users, the foreign keys won’t break.
So, think about this scenario. A user has created an account and verified successfuly. Then admin decided to ban this user and set its isActive flag to false. User is now able to request verification mail (re-send) and set own isActive flag to true.
What do you think about this problem? Thank you.
While using with DRF, I had to convert the serializer of a model to the corresponding form. I feel It would be good to support DRF serializers. Thanks for the useful library.
I'm using default templates and the verification link does not have an href attribute:
<a class="m_-5654556666167927182my-button">Verify</a>
seems like {{link}} is not working properly.
Hi,first of all thank you so much for making such an awesome Third party package for Django. can you help me out in two main issues i have
Thanks and sorry for the trouble
Email verification send an invalid link all the time
Invalid Link
This link is invalid or been used already, we cannot verify using this link.
When I am on life server, the Verify Email is sending InvalidToken.
The message I got is:
"Invalid Link
This link is invalid or been used already, we cannot erify using this link."
I have tried with many people same issue.
How can I make this to send valid token.
Thanks.
Isaac Bejide;
I could really use the ability to send invites without a form.
Django-Verify-Email is awesome but I have an issue.
The problem is that, when the user clicks on register, before verifying through gmail, the user gets registered in database as a non-active user.
If not verified, the user cannot login, which is good but if user can't verify for some reason and tries to register again, the username shows 'taken'. So is there any solution for this, which I'm not aware of ??
In other words how would I make them retry for verification, even if the user is registered ??
Django-Verify-Email/verify_email/views.py
Lines 166 to 170 in 5ba6f64
According to the current documentation the default url for auth views is /accounts/ not /account/.
Hi,
It seems that verification doesn't work until I set the "LOGIN_URL" variable in my settings.py.
If I don't do this and press on the "Verify" button in my e-mail I get this:
Refreshing or reclicking the button gives me the "Verification Failed" page. And indeed my user isn't activated. However when I set the "LOGIN_URL" variable in my settings.py everything works.
I use the standard Django authentication urls implemented by this line:
path('accounts/', include('django.contrib.auth.urls'))
Is it not better to authenticate user right after verification instead of redirecting him to the login page?
Probably we can add new setting variable to control this behavior.
Hello, it's not really an issue actually but I'm confused about how to implement your project in my project. My project use a username as the authentication key. So the first user will have to register and their password, and then that information will be saved. After that user will completing a signup form with their details and e-mail field in it. Now, everytime I try to implement send_verification_email in my second sign up form I always get an error that says foreign key constrained error. My guess because your project save the user, and my project also save the form and user django just doesn't know which user to save. Do I need to rework my project or is there any way I can implement your application in my project. Let me know if you need more information I would be glad to help. Thank you
Hi,
I cannot find any instructions on how to send verification e-mail again after user for example accidentally deletes the firts e-mail. Any suggestions?
Also I'm having trouble using custom templates - followed the tutorial from the documentation but it doesn't work :(
Could you show example on hot specify the path to the template(with project structure)?
Appreciate your help
Hi, I am very new to Django and I followed all the steps. I still could not send the verification email. On creation of a new account it set the account to inactive but it did not send the email address a verification email. Please do advise on how to proceed, I think it might be a mail server issue. Attaching my mail server config here, please do let me know what I am doing wrong.
Thanks in advance!
Issue is on this line:
When you register using an unused email, everything works perfectly. The issue arises when you register again using the same email address, which is allowed by default in Django. This results in the first item getting picked, which is the one created earlier. The verification token will not match and you'll land on an error page. Maybe it's a good idea to sort by date_joined
to prevent this from wrongly happening?
Hey there,
Great plugin, thanks :)
It would be useful if the account was created separately to the send_verification_email() step.
The reasoning is that something could go wrong during the sending of the verification email (SMTP relay unavailable). In this event the whole transaction is lost - whereas it would be better to keep it, and retry email sending later.
I think it might be useful to have this feature in this app?
Hi
I got error same as #49
when new user click on [verify] link, this error well show:
"Invalid Link This link is invalid or been used already, we cannot verify using this link."
http://domain.ltd/verification/user/verify-email/aGlwc2FuaXJ0aUB2dXNyYS5jb20=/YjYwbGhnLWE5ZTM2YzExZWJlYTFkY2E4NjQ4ZmM3NzUwNjI4ZGRl/
`from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser):
name = models.CharField(max_length=100, blank=True, null=True)
`
Email inherited from AbstractUser
any idea how to fix it?
I keep on getting this issue:-
NoReverseMatch at /verification/user/verify-email/dGVzdEBnbWFpbC5jb20=/Ymt2OGowLWJlM2ZkMWZmNTgxMWIyYjFjNzNiYjIwYTgyMjg3MjBh/
Reverse for 'accounts.views.login' not found. 'accounts.views.login' is not a valid view function or pattern name.
Which indeed exists under accounts/urls.py and the function is at accounts/views.py
accounts/urls.py
urlpatterns = [ path('login/', views.login, name='login'), ]
And when I looked into the app_configurations.py file I found that the LOGIN_URL parameter was taking a default value which was not present in the application. So, I tried adding that under my_project/settings.py
LOGIN_URL = 'accounts.views.login'
But, I do not know why it again throws the same error.
Can you please tell me where I'm going wrong
Thank you
PS: I have also attached a image of the error here
User is successfully able to verify his email but in the password field i see this error : Invalid password format or unknown hashing algorithm.
and thus i cant login.
This is my view:
form = RegistrationForm()
if request.method == "POST":
form = RegistrationForm(request.POST)
if form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password"]
print(type(password))
email = form.cleaned_data["email"]
confirmPassword = form.cleaned_data["confirmpassword"]
pattern = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b"
if not re.match(r"^[a-zA-Z][a-zA-Z0-9._]{3,11}$", username):
return render(
request,
"photos/register_form.html",
{
"error": "Username must start with a letter, should be 4 to 12 characters long, and can contain letters, numbers, periods, and underscores."
},
)
if re.fullmatch(pattern, email) == None:
return render(
request,
"photos/register_form.html",
{"error": "Not a valid email address"},
)
if len(username) < 3:
return render(
request,
"photos/register_form.html",
{"error": "Username must be at least 3 characters long"},
)
if len(password) < 8:
return render(
request,
"photos/register_form.html",
{"error": "Password must be at least 8 characters long"},
)
if User.objects.filter(username=username).exists():
return render(
request,
"photos/register_form.html",
{"error": "Username is already taken"},
)
if User.objects.filter(email=email).exists():
return render(
request,
"photos/register_form.html",
{"error": "Email is already in use"},
)
if password == confirmPassword:
# user = User.objects.create_user(username=username, email=email, password=password,user_bio='',pfp=None,is_verified=False,otp='')
inactive_user= send_verification_email(request, form)
# user.save()
# if user is not None:
# user.backend = "django.contrib.auth.backends.ModelBackend"
# login(request, user)
# return redirect("gallery")
# else:
# return render(
# request,
# "photos/register_form.html",
# {"error": "Something went wrong "},
# )
else:
return render(
request,
"photos/register_form.html",
{"error": "Password and confirm password doesn't match "},
)
return render(request, "photos/register_form.html",{"form": form})
Whenever a user makes a registartion I get an email that the token is invalid. However, when the user is already registered and decides to change thier email address there are no issues with that. It used to function with no issues at all and I can't find out the cause of this problem.
Hi there,
what is the best way to add verify_email
into existing project that has active users already?
I want the users to gradually verify their emails without affecting the way they use rest of the system much.
If I install this library it expects linkcounter
one to one relation to exist for each user. But this related model instance gets created for new users only.
What is the migration to mitigate this?
Should I create a data migration that creates verify_email_linkcounter
data entry for each existing user?
Should the default sent_count
be zero in this case?
Sorry I'm new to github and idk if this is a real issue but I spent hours downloading this package but it turns out the link was for v0.0.5.
https://pypi.org/project/Django-Verify-Email/
Thank you for your work on this package!
Is this project still actively maintained? Is there a chance to add maintainers to help ease the load? I would very much appreciate using this repository as a common base rather than having to maintain a separate fork.
Kindest regards
Sebastian
HI,
i followed the instruction given for this package on https://pypi.org/ but I am getting this error.
this is view.py
and this is the error
is it something wrong in my app or is it an issue in the package
First off: Thank you for your timing creating this library. It is very much appreciated!
I encountered a little issue when re-requesting a token in your latest update:
ValueError at /verification/user/verify-email/request-new-link/
The view verify_email.views.request_new_link didn't return an HttpResponse object. It returned None instead.
Django Version: 3.2.6
Python Version: 3.9.12
Library Version: 2.0.1
After a little investigation, I found that the issues is a result from your newly introduced form:
class RequestNewVerificationEmail(forms.ModelForm):
class Meta:
model = get_user_model()
fields = ['email']
(forms.py)
Now, I got a custom user model like this:
class CustomUser(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
username = None
email = models.EmailField(
unique=True, verbose_name=_("email address"), help_text=_("Your email address.")
)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
objects = CustomUserManager()
def __str__(self):
return self.email
By adding the unique=True
flag on the email field, your form fails to validate since the email address that is entered again as a confirmation already exists in the database and Django tries to guard from a double insertion. Now I assume that adding a unique flag on the email column is a fairly reasonable thing to do, especially for those use cases where you don't have an additional username.
Changing RequestNewVerificationEmail
to the following resolves the issue in a way that is probably even a bit more robust against all kinds of different custom user model configurations:
class RequestNewVerificationEmail(forms.Form):
email = forms.EmailField(
label=get_user_model()._meta.get_field("email").verbose_name,
help_text=get_user_model()._meta.get_field("email").help_text,
)
Please let me know what you think, I'll be happy to provide a PR for this.
Currently the email sending mechanism doesn't pass the new user into the email context, which means we cant add personalisations such as the persons name, email address, or username.
My pull request addresses this
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.