def service_resend_confirmation(): token = current_user.generate_confirmation_token() send_email(current_user.email, 'Confirm Your Account', 'auth/email/confirm_service', user = current_user, token = token) data = {'message' : 'A new confirmation email has been sent to you by email.', 'success': True } return jsonify(data)
def resend_confirmation(): token = current_user.generate_confirmation_token() send_email(current_user.email, 'Confirm Your Account', 'auth/email/confirm', user=current_user, token=token) flash('A new confirmation email has been sent to you by email.') return redirect(url_for('main.index'))
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() token = user.generate_confirmation_token() send_email(user.email, 'Confirm Your Account', 'auth/email/confirm', user=user, token=token) flash('A confirmation email has been sent to you by email.') return redirect(url_for('main.index')) return render_template('auth/register.html', form=form)
def service_register(): params = json.loads(request.get_data(cache=False, as_text=True)) data = dict() form = RegistrationForm.from_json(params) if form.validate_on_submit(): user = User(email = form.email.data, username = form.username.data, password = form.password.data) db.session.add(user) db.session.commit() token = user.generate_confirmation_token() send_email(user.email, 'Confirm Your Account', 'auth/email/confirm_service', user=user, token=token) data = { 'message' : 'A confirmation email has been sent to you by email.', 'success': True } else: data = { 'error' : form.errors, 'success': False } return jsonify(data)
def test_send_mail(self): user = User(username='******', email='*****@*****.**', password='******', confirmed=True) subject = 'Your Flasky account credentials' template = 'auth/email/oauth_confirm' msg = send_email(user.email, subject, template, user=user, password='******') self.assertIsInstance(msg, Message)