예제 #1
0
파일: views.py 프로젝트: olegv11/Banki
def create_user_google():
    user = User()

    user.name = request.values['name']
    user.mail = request.values['mail']
    user.google_access_token = request.values['access_token']

    if User.query.filter_by(mail=user.mail).first() is not None:
        return jsonify({'status': 'Name exists'})

    db.session.add(user)
    db.session.commit()
    return jsonify({'id': user.id})
예제 #2
0
파일: views.py 프로젝트: olegv11/Banki
def create_user():
    user = User()
    unencrypted_password = request.values['password']

    user.name = request.values['name']
    user.password = encrypt(unencrypted_password)
    user.mail = request.values['mail']
    user.role = 'user'
    if 'role' in request.values:
        user.role = request.values['role']

    if User.query.filter_by(name=user.name).first() is not None:
        return jsonify({'status': 'Name exists'})

    if User.query.filter_by(mail=user.mail).first() is not None:
        return jsonify({'status': 'Name exists'})

    db.session.add(user)
    db.session.commit()
    return jsonify({'id': user.id})