Skip to content

Commit 099707e

Browse files
committed
improve
1 parent 173032a commit 099707e

File tree

1 file changed

+12
-7
lines changed
  • x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative

1 file changed

+12
-7
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void getUserAndPassword(final String user, final ActionListener<UserAndP
241241
() -> executeAsyncWithOrigin(
242242
client.threadPool().getThreadContext(),
243243
SECURITY_ORIGIN,
244-
client.prepareGet(SECURITY_MAIN_ALIAS, getIdForUser(USER_DOC_TYPE, user)).request(),
244+
client.prepareGet(SECURITY_MAIN_ALIAS, getIdForUser(getDocType(user), user)).request(),
245245
new ActionListener<GetResponse>() {
246246
@Override
247247
public void onResponse(GetResponse response) {
@@ -280,12 +280,7 @@ public void onFailure(Exception t) {
280280
*/
281281
public void changePassword(final ChangePasswordRequest request, final ActionListener<Void> listener) {
282282
final String username = request.username();
283-
final String docType;
284-
if (ClientReservedRealm.isReserved(username, settings)) {
285-
docType = RESERVED_USER_TYPE;
286-
} else {
287-
docType = USER_DOC_TYPE;
288-
}
283+
final String docType = getDocType(username);
289284

290285
securityIndex.forCurrentProject().prepareIndexIfNeededThenExecute(listener::onFailure, () -> {
291286
executeAsyncWithOrigin(
@@ -330,6 +325,16 @@ public void onFailure(Exception e) {
330325
});
331326
}
332327

328+
private String getDocType(String username) {
329+
final String docType;
330+
if (ClientReservedRealm.isReserved(username, settings)) {
331+
docType = RESERVED_USER_TYPE;
332+
} else {
333+
docType = USER_DOC_TYPE;
334+
}
335+
return docType;
336+
}
337+
333338
/**
334339
* Asynchronous method to create the elastic superuser with the given password hash. The cache for the user will be
335340
* cleared after the document has been indexed.

0 commit comments

Comments
 (0)