Account REST API: fix the key setting in RestApiServlet

The previous code creates a new PropertyKey both in RestApiServlet and
GetExternalIds. These two keys are actually different, which must be the
same to get the right external id.

Add a PropertyKey in CurrentUser to get the external id. It can't be added in
IdentifiedUser as the RestApiServlet will be called by anonymous users, too.

Change-Id: If1f4a31e3fc2c781c99aad786de4e741ee626e06
This commit is contained in:
Changcheng Xiao
2017-01-13 14:46:08 +01:00
parent f2d9589fed
commit 1746cee4d0
3 changed files with 15 additions and 6 deletions

View File

@@ -72,9 +72,8 @@ public class GetExternalIds implements RestReadView<AccountResource> {
// establish this web session, and if only if an identity was
// actually used to establish this web session.
if (!id.isScheme(SCHEME_USERNAME)) {
CurrentUser.PropertyKey<AccountExternalId.Key> k =
CurrentUser.PropertyKey.create();
AccountExternalId.Key last = resource.getUser().get(k);
AccountExternalId.Key last = resource.getUser()
.getLastLoginExternalIdKey();
info.canDelete =
toBoolean(last != null && !last.get().equals(info.identity));
}