def get_or_create_user(auth_user): user = User() # Returns None or List[User] objects - could be more than one users = user.get_user_by_username(str(auth_user.username)) if users is None: user.set_user_id(str(uuid.uuid4())) user.set_user_name(auth_user.name) user.set_lf_email(auth_user.email.lower()) user.set_lf_username(auth_user.username) user.set_lf_sub(auth_user.sub) user.save() event_data = f'CLA user added for {auth_user.username}' Event.create_event( event_data=event_data, event_type=EventType.CreateUser, contains_pii=True, ) return user # Just return the first matching record return users[0]
def get_or_create_user(auth_user): user = User() existing_user = user.get_user_by_username(str(auth_user.username)) if existing_user is None: user.set_user_id(str(uuid.uuid4())) user.set_user_name(auth_user.name) user.set_lf_email(auth_user.email.lower()) user.set_lf_username(auth_user.username) user.set_lf_sub(auth_user.sub) user.save() return user return existing_user
def get_or_create_user(auth_user): user = User() # Returns None or List[User] objects - could be more than one users = user.get_user_by_username(str(auth_user.username)) if users is None: user.set_user_id(str(uuid.uuid4())) user.set_user_name(auth_user.name) user.set_lf_email(auth_user.email.lower()) user.set_lf_username(auth_user.username) user.set_lf_sub(auth_user.sub) user.save() return user # Just return the first matching record return users[0]