Check if identity was updated when updating user (Follow-up from "Exposing saml_provider_id in the users API")

The following discussion from !14045 (merged) should be addressed:

  • @jprovaznik started a discussion: (+6 comments)

    Currently we don't check if identity was updated or not. WDYT about something like:

    identity = assign_identity
    identity_errors = identity&.errors || []
    
    if identity_errors.empty? && @user.save(validate: validate) && update_status
      notify_success(user_exists)
    else
      messages = identity_errors.full_messages + @user.errors.full_messages + Array(@user.status&.errors&.full_messages)
      ...

    assign_identity method would have to return identity object (instead of save/update return value):

        def assign_identity
          return if identity_params.empty?
    
          identity = find_identity(user)
          if identity
            identity.update(identity_params)
          else
            identity = user.identities.build(identity_params)
            identity.save
          end
    
          identity
        end
    

/cc @leopardm @jamedjo - could you please check/update milestone/labels?

Assignee Loading
Time tracking Loading