Skip to content
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

Problem in password after user gets verified. #72

Open
Dhruvil2511 opened this issue Oct 13, 2023 · 0 comments
Open

Problem in password after user gets verified. #72

Dhruvil2511 opened this issue Oct 13, 2023 · 0 comments

Comments

@Dhruvil2511
Copy link

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})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant