Exemplo n.º 1
0
    def send_verification_email(unverified_user):
        recipient = unverified_user.email
        verification_link = CompleteSignup.build_link(unverified_user)

        template_values = {
            'verification_link': verification_link,
        }

        body = shared_jinja.template_to_string(
            'verification-email-text-only.html', template_values)

        if not App.is_dev_server:
            mail.send_mail(
                sender='Khan Academy Accounts <*****@*****.**>',
                to=recipient,
                subject="Verify your email with Khan Academy",
                body=body)
Exemplo n.º 2
0
    def send_verification_email(unverified_user):
        recipient = unverified_user.email
        verification_link = CompleteSignup.build_link(unverified_user)

        template_values = {
                'verification_link': verification_link,
            }

        body = shared_jinja.template_to_string(
                'verification-email-text-only.html',
                template_values)

        if not App.is_dev_server:
            mail.send_mail(
                    sender='Khan Academy Accounts <*****@*****.**>',
                    to=recipient,
                    subject="Verify your email with Khan Academy",
                    body=body)
Exemplo n.º 3
0
    def post(self):
        email = self.request_string("email", default=None)
        if not email:
            self.render_jinja2_template('forgot-password.html', {})
            return

        user_data = user_models.UserData.get_from_user_input_email(email)
        if not user_data or not user_data.has_password():
            # TODO(benkomalo): separate out the case where we detected a user
            # but he/she doesn't have a password set?
            self.render_jinja2_template(
                'forgot-password-error.html', {
                    'email': email,
                    'google_url': users.create_login_url('/completesignup'),
                })
            return

        reset_url = PasswordReset.build_link(user_data)
        template_values = {
            'name': user_data.nickname,
            'url': reset_url,
        }
        body = shared_jinja.template_to_string(
                'password-reset-email-text-only.html',
                template_values)

        if not App.is_dev_server:
            mail.send_mail(
                    sender="Khan Academy Accounts <*****@*****.**>",
                    to=email,
                    subject="Khan Academy account recovery",
                    body=body)

        template_values =  {
            'sent_email': email,
        }
        if App.is_dev_server:
            template_values['debug_link'] = reset_url
        self.render_jinja2_template('forgot-password.html', template_values)
Exemplo n.º 4
0
    def post(self):
        email = self.request_string("email", default=None)
        if not email:
            self.render_jinja2_template('forgot-password.html', {})
            return

        user_data = user_models.UserData.get_from_user_input_email(email)
        if not user_data or not user_data.has_password():
            # TODO(benkomalo): separate out the case where we detected a user
            # but he/she doesn't have a password set?
            self.render_jinja2_template(
                'forgot-password-error.html', {
                    'email': email,
                    'google_url': users.create_login_url('/completesignup'),
                })
            return

        reset_url = PasswordReset.build_link(user_data)
        template_values = {
            'name': user_data.nickname,
            'url': reset_url,
        }
        body = shared_jinja.template_to_string(
            'password-reset-email-text-only.html', template_values)

        if not App.is_dev_server:
            mail.send_mail(
                sender="Khan Academy Accounts <*****@*****.**>",
                to=email,
                subject="Khan Academy account recovery",
                body=body)

        template_values = {
            'sent_email': email,
        }
        if App.is_dev_server:
            template_values['debug_link'] = reset_url
        self.render_jinja2_template('forgot-password.html', template_values)
Exemplo n.º 5
0
 def render_jinja2_template_to_string(self, template_name, template_values):
     return shared_jinja.template_to_string(template_name, template_values)
Exemplo n.º 6
0
 def render_jinja2_template_to_string(self, template_name, template_values):
     return shared_jinja.template_to_string(template_name, template_values)