PhenoApps / Field-Book

https://fieldbook.phenoapps.org
GNU General Public License v2.0
47 stars 55 forks source link

[BUG]: "OIDC Client ID" setting is overriding "OIDC Discovery URL" setting #976

Open BrapiCoordinatorSelby opened 1 month ago

BrapiCoordinatorSelby commented 1 month ago

Description

In the Settings >> BrAPI >> Auth Settings menu, any edit to the setting "OIDC Client ID" will also edit the value of "OIDC Discovery URL" to match. Even opening the dialog box will cause the overwrite to occur. If you need to edit the Client ID, the current work around is to copy the Discovery URL, then edit the client ID, then paste the Discovery URL value back in that setting.

Expected behavior

These settings should be totally independent from each other. Setting one should not affect the other

Field Book version

5.6.19

BrapiCoordinatorSelby commented 1 month ago

I did some digging and I think I found the root cause. BrapiPreferencesFragment.java line 423

    @Override
    public void onDisplayPreferenceDialog(Preference preference) {
        // check if dialog is already showing
        if (getFragmentManager() != null && getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
            return;
        }

        final DialogFragment f;

 ---->  if (preference instanceof NeutralButtonEditTextDialog) {

            /*
             * Takes three callbacks, on neutral (barcode scan), positive (save to prefs), negative (do nothing)
             */
            f = NeutralButtonEditTextDialogFragmentCompat.Companion.newInstance(preference.getKey(), (dialog, text) -> {

This code is intended to update the Discovery URL if the Base URL changes. The new settings added (client ID and scope) in #927 are both instances of NeutralButtonEditTextDialog and they are tripping this if statement. The if statement should be changed to only allow the Base URL to trigger this code, instead of any NeutralButtonEditTextDialog

This is an untested theory, just looking at raw code on github. I don't have time right now to fully test a fix and submit a pull request.