Beispiel #1
0
 def customize(self, app):
     from flask_user.email_adapters import SendmailEmailAdapter
     from flask_user.email_adapters import SendgridEmailAdapter
     from flask_user.email_adapters import SMTPEmailAdapter
     email_adapter = SendmailEmailAdapter(app)
     email_adapter = SendgridEmailAdapter(app)
     email_adapter = SMTPEmailAdapter(app)
Beispiel #2
0
    def customize(self, app):
        # Add the email field
        class CustomUserProfileForm(EditUserProfileForm):
            email = StringField("Email",
                                validators=[validators.DataRequired()])

        self.EditUserProfileFormClass = CustomUserProfileForm

        # Add the reCaptcha
        if app.config.get("DISPLAY_RECAPTCHA"):

            class CustomRegisterForm(RegisterForm):
                recaptcha = RecaptchaField()

            self.RegisterFormClass = CustomRegisterForm

        # Allow emails to be send using sendmail
        if app.config.get("EMAIL_ADAPTER") == "sendmail":
            from flask_user.email_adapters import SendmailEmailAdapter

            self.email_adapter = SendmailEmailAdapter(app)
Beispiel #3
0
    def customize(self, app):
        def _unique_email_validator(form, field):
            """
            Check if the new email is unique. Skip this step if the
            email is the same as the current one.
            """
            if field.data.lower() == current_user.email.lower():
                return
            unique_email_validator(form, field)

        # Add the email field and make first and last names as not required
        class CustomUserProfileForm(EditUserProfileForm):
            first_name = StringField("First name")
            last_name = StringField("Last name")
            email = StringField(
                "Email",
                validators=[
                    validators.DataRequired(),
                    validators.Email(),
                    _unique_email_validator,
                ],
            )

        self.EditUserProfileFormClass = CustomUserProfileForm

        # Add the reCaptcha
        if app.config.get("DISPLAY_RECAPTCHA"):

            class CustomRegisterForm(RegisterForm):
                recaptcha = RecaptchaField()

            self.RegisterFormClass = CustomRegisterForm

        # Allow emails to be send using sendmail
        if app.config.get("EMAIL_ADAPTER") == "sendmail":
            from flask_user.email_adapters import SendmailEmailAdapter

            self.email_adapter = SendmailEmailAdapter(app)