weizhouapache commented on PR #12632:
URL: https://github.com/apache/cloudstack/pull/12632#issuecomment-3889893712

   
   
   
   > > @DaanHoogland can we use this method `UserAccountDao.getUserByApiKey` 
instead ?
   > 
   > no doubt, but can you be more specific? Do you mean, bypass 
`findUserAccountByApiKey` altogether? Or call `UserAccountDao.getUserByApiKey` 
from within it. I am sure you mean to suggest a cleanup refactor, but that is 
as far as my understanding goes.
   > 
   > Note `findUserAccountByApiKey` is called in three places. Happy to make 
this PR more elaborate.
   
   @DaanHoogland 
   I had a quick look, I think remove the method 
`accountDao.findUserAccountByApiKey(apiKey)`, and use this method instead
   
   ```
   --- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java
   +++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java
   @@ -3051,7 +3051,9 @@ public class AccountManagerImpl extends ManagerBase 
implements AccountManager, M
    
        @Override
        public Pair<User, Account> findUserByApiKey(String apiKey) {
   -        return _accountDao.findUserAccountByApiKey(apiKey);
   +        UserAccount userAccount = _userAccountDao.getUserByApiKey(apiKey);
   +        // TODO: get User and Account from userAccount or from DB
   +        return new Pair<>(user, account);
        }
    
        @Override
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to