Changeset 15757 in josm for trunk


Ignore:
Timestamp:
2020-01-25T16:11:37+01:00 (5 years ago)
Author:
GerdP
Message:

fix #11914: show OSM username in titlebar

  • update UserIdentityManager when CredentialsManager is updated.
  • call purgeCredentialsCache() when user is changed so that we don't use previously user when the new user+password combination is bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java

    r12992 r15757  
    132132            }
    133133        }
     134        // see #11914: clear cache before we store new value
     135        purgeCredentialsCache(requestorType);
    134136        delegate.store(requestorType, host, credentials);
    135137    }
     
    138140    public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse)
    139141            throws CredentialsAgentException {
    140         return delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
     142        CredentialsAgentResponse credentials = delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
     143        if (requestorType == RequestorType.SERVER) {
     144            // see #11914 : Keep UserIdentityManager up to date
     145            String userName = credentials.getUsername();
     146            userName = userName == null ? "" : userName.trim();
     147            if (!Objects.equals(UserIdentityManager.getInstance().getUserName(), userName)) {
     148                if (userName.isEmpty())
     149                    UserIdentityManager.getInstance().setAnonymous();
     150                else
     151                    UserIdentityManager.getInstance().setPartiallyIdentified(userName);
     152            }
     153        }
     154        return credentials;
    141155    }
    142156
Note: See TracChangeset for help on using the changeset viewer.