Skip to content
Snippets Groups Projects
Commit df4a5607 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Set a temp password on user activation so users who skip setting one can use...

Set a temp password on user activation so users who skip setting one can use the password reset function.
parent fe0d78d6
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model, login, update_session_auth_hash ...@@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model, login, update_session_auth_hash
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AdminPasswordChangeForm from django.contrib.auth.forms import AdminPasswordChangeForm
from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.models import BaseUserManager
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.urls import reverse_lazy from django.urls import reverse_lazy
...@@ -71,6 +72,9 @@ class ActivationView(TemplateView): ...@@ -71,6 +72,9 @@ class ActivationView(TemplateView):
if self.valid(user, kwargs.get('token')): if self.valid(user, kwargs.get('token')):
user.is_active = True user.is_active = True
# Set a temp password so users who skip setting one can use the password reset function.
temp_pass = BaseUserManager().make_random_password(length=32)
user.set_password(temp_pass)
user.save() user.save()
user.backend = 'django.contrib.auth.backends.ModelBackend' user.backend = 'django.contrib.auth.backends.ModelBackend'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment