コード例 #1
0
def join(room_code):
    room = Room.query.filter_by(code=room_code).first_or_404()
    new_user_form = NewUserForm()
    if new_user_form.validate_on_submit():
        user = User(name=new_user_form.name.data, room_code=room_code)
        db.session.commit()
        login_user(user)
        flash(f"Joined {room.name}")
        return redirect(url_for('member_view', room_code=room.code))
    return render_template('join.html',
                           title='Join room',
                           room=room,
                           form=new_user_form)
コード例 #2
0
ファイル: views.py プロジェクト: Estaire/info3180-project2
def register():
    form = NewUserForm()
    if form.validate_on_submit() and request.method == 'POST':
        user = UserProfile(request.form['email'], request.form['firstname'],
                           request.form['lastname'], request.form['username'],
                           request.form['password'], "", "", "")
        db.session.add(user)
        db.session.commit()
        access_token = create_access_token(identity=request.form['username'])
        return jsonify({
            'authenticated': True,
            'access_token': access_token
        }), 200
    return jsonify(response=form_errors(form))