예제 #1
0
def _upsert_user(ldap_info):
    user = session.query(UserModel).filter(UserModel.uid == ldap_info.uid).first()

    if user is None:
        # Add new user
        user = UserModel()
    else:
        user = session.query(UserModel).filter(UserModel.uid == ldap_info.uid).with_for_update().first()

    user.uid = ldap_info.uid
    user.ldap_info = ldap_info

    session.add(user)
    session.commit()
    return user
예제 #2
0
def _upsert_user(user_info):
    user = db.session.query(UserModel).filter(
        UserModel.uid == user_info.uid).first()

    if user is None:
        # Add new user
        user = UserModel()
    else:
        user = db.session.query(UserModel).filter(
            UserModel.uid == user_info.uid).with_for_update().first()

    user.uid = user_info.uid
    user.display_name = user_info.display_name
    user.email_address = user_info.email_address
    user.affiliation = user_info.affiliation
    user.title = user_info.title

    db.session.add(user)
    db.session.commit()
    return user