1

Hi i am using python flask Flask-Security.

I want to make users confirm their emails but not their passwords.

It doesn't ask the user to enter in their password and another input to confirm passwords are matching.

Instead it just asks the user for one password.

SECURITY_CONFIRMABLE asks users are required to confirm their email address when registering a new account.

I want to users to confirm thier email but not check if passwords are matching on signup.

Holly Johnson
  • 509
  • 1
  • 13
  • 25

2 Answers2

1

The RegisterForm from Flask-Security is inherit from ConfirmRegisterForm, PasswordConfirmFormMixin and NextFormMixin. You should import ConfirmRegisterForm and NextFormMixin from Flask-Security and define a custom RegisterForm which only inherit from ConfirmRegisterForm and NextFormMixin.

from flask-security import ConfirmRegisterForm, NextFormMixin

class CustomRegisterForm(ConfirmRegisterForm, NextFormMixin):
    def __init__(self, *args, **kwargs):
        super(CustomRegisterForm, self).__init__(*args, **kwargs)
        if not self.next.data:
            self.next.data = request.args.get('next', '')

Rewrite the configuration of Flask-Security:

app["SECURITY_REGISTER_FORM"] = CustomRegisterForm
stamaimer
  • 6,227
  • 5
  • 34
  • 55
0

If you use SECURITY_CONFIRMABLE = True and want to use password confirmation while registration simply add to the config file or application configuration:

from flask_security import RegisterForm
SECURITY_CONFIRM_REGISTER_FORM = RegisterForm
# or use this: app["SECURITY_CONFIRM_REGISTER_FORM"] = RegisterForm

This works with Flask-Security==3.0.0