Ejemplo n.º 1
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('investments.dashboard', username=current_user.username))
    form = RegistrationForm()
    if form.validate_on_submit():
        email = form.email.data
        username = form.username.data
        # date_of_birth = form.date_of_birth.data or None
        date_of_birth = None
        first_name = form.first_name.data
        last_name = form.last_name.data or None
        password = form.password.data
        user = UserProfile(username=username, email=email, first_name=first_name,
                           password=password, last_name=last_name, date_of_birth=date_of_birth)
        db.session.add(user)
        db.session.commit()
        token = user.get_reset_password_token()
        send_email('Activate your account',
                   sender=current_app.config['ADMINS'][0],
                   recipients=[user.email],
                   text_body=render_template('account_activate.txt', user=user, token=token),
                   html_body=render_template('account_activate_email_format.html', user=user, token=token))
        flash('Thanks for registering with us!Please check you mail for activating you account.')
        return redirect(url_for('accounts.login'))
    else:
        print(form.errors)
    return render_template('register.html', form=form)
Ejemplo n.º 2
0
    def send_email(self, app, category):
        output_dir = os.getcwd() + "/logs/%s/%s" % (self.project_id, self.build_no)
        output_dir = output_dir.replace("\\", "/")
        while not os.path.exists(output_dir + "/output.xml"):
            sleep(1)
        if category == 'http':
            sleep(10)
        elif category == 'web':
            sleep(30)
        else:
            sleep(100)

        res = self.__parser_summary()
        report_url = output_dir + "/report.html"
        log = codecs.open(output_dir + "/logs.log", "r", encoding="cp936").read().replace("\n", "<br>")
        send_email(app, res['name'], self.build_no, res['status'], res['starttime'], res['endtime'], report_url, log)
Ejemplo n.º 3
0
def send_password_reset_email():
    form = SendResetPasswordRequestForm()
    if form.validate_on_submit():
        email = form.email.data
        user = UserProfile.query.filter_by(email=email).first()
        if user is not None:
            token = user.get_reset_password_token()
            send_email('Reset Your Password',
                       sender=current_app.config['ADMINS'][0],
                       recipients=[user.email],
                       text_body=render_template('reset_password.txt', user=user, token=token),
                       html_body=render_template('reset_password_email_format.html', user=user, token=token))
            return redirect(url_for('accounts.login'))
        else:
            flash('This email is not registered with us.')
    return render_template('send_reset_password_request.html', form=form)
Ejemplo n.º 4
0
 def send_recovery_email(user):
     recovery_token = user.generate_auth_token(expiration=120)
     link = url_for("user_mgmt.get_do_password_reset", _external=True, token=recovery_token)
     body = render_template("user_mgmt/recovery_email.html", link=link, user=user)    
     subject = "Grubgreat password recovery."
     send_email(body=body, subject=subject, email_address=user.email)