Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4525 Zobrazení

When I create new account from website, I need to click Click here to send verification email allowing you participate at the elearning in elearning courses.I don't want to click this and want to automatically send verification email .How can I solve that? I try to add in sign up function but not work. Here is my code for sign up

@http.route('/web/signup', type='http', auth='public', website=True, sitemap=False)
    def web_auth_signup(self, *args, **kw):
        qcontext = self.get_auth_signup_qcontext()
        qcontext['countries'] = request.env['res.country'].sudo().search([])

        if not qcontext.get('token') and not qcontext.get('signup_enabled'):
            raise werkzeug.exceptions.NotFound()

        if 'error' not in qcontext and request.httprequest.method == 'POST':
            try:
                self.do_signup(qcontext)
                # Send an account creation confirmation email
                if qcontext.get('token'):
                    user_sudo = request.env['res.users'].sudo().search([('login', '=', qcontext.get('login'))])
                    template = request.env.ref('auth_signup.mail_template_user_signup_account_created',
                                               raise_if_not_found=False)
                    if user_sudo and template:
                        template.sudo().with_context(
                            lang=user_sudo.lang,
                            auth_login=werkzeug.url_encode({'auth_login': user_sudo.email}),
                        ).send_mail(user_sudo.id, force_send=True)
                return self.web_login(*args, **kw)
            except UserError as e:
                qcontext['error'] = e.name or e.value
            except (SignupError, AssertionError) as e:
                if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]):
                    qcontext["error"] = _("Another user is already registered using this email address.")
                else:
                    _logger.error("%s", e)
                    qcontext['error'] = _("Could not create a new account.")

        response = request.render('auth_signup.signup', qcontext)
        response.headers['X-Frame-Options'] = 'DENY'
        if request.env.uid != request.website.user_id.id:
            logging.info("Sending Email+++++++++++++++++++++++++++++++")
            request.env.user._send_profile_validation_email(**kwargs)
        logging.info(request.env.user.name)
        logging.info("user name+++++++++++++++++++++")
        request.session['validation_email_sent'] = True

        return response
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
srp 24
3898
4
úno 23
7035
0
čvn 20
2536
1
říj 19
11320
0
říj 23
4111