def register_post(): if current_user.is_authenticated(): return redirect(url_for('front_page')) form = RegistrationForm(request.form) if form.validate(): user_dict = { "email": form.email.data, "password": form.password.data } u = register_user(**user_dict) u.created_at=datetime.datetime.utcnow() u.modified_at=datetime.datetime.utcnow() u.first_name=form.first_name.data u.last_name=form.last_name.data u.ran_through_first_run_wizard=False custom_questions = dict() for c in form.custom_fields(): custom_questions[c.id] = c.data u.custom_questions_json = custom_questions db.session.add(u) db.session.commit() g.user = u login_user(u, force=True) flash('You were successfully logged in') return redirect(url_for('front_page')) else: return render('register.html', form=form)
def register_facebook_account_post(): if current_user.is_authenticated(): return redirect(url_for('front_page')) registration_form = RegistrationForm(request.form) registration_form.validate() pw = registration_form.password.data user_dict = { "email": registration_form.email.data, "password": registration_form.password.data } u = register_user(**user_dict) u.created_at=datetime.datetime.utcnow() u.modified_at=datetime.datetime.utcnow() u.first_name=registration_form.first_name.data u.last_name=registration_form.last_name.data u.ran_through_first_run_wizard=False custom_questions = dict() for c in registration_form.custom_fields(): custom_questions[c.id] = c.data u.custom_questions_json = custom_questions auth = FacebookUser.query.filter_by(id=session['fb_auth']).first() u.profile_image = 'https://graph.facebook.com/%s/picture' % auth.facebook_id auth.user = u db.session.add(u) db.session.add(auth) db.session.commit() if auth.user is not None: g.user = auth.user login_user(auth.user, force=True) flash('You were successfully logged in') return redirect(url_for('front_page'))