IDEMPIERE-5169 OAuth2: add same email account on other client will break it on old client (#1146)
* IDEMPIERE-5169 OAuth2: add same email account on other client will break it on old client * Fix wrong SQL - thanks to HiepLq * Fix wrong parameters - thanks to HiepLq
This commit is contained in:
parent
496fce5434
commit
824e1bb2da
|
@ -100,24 +100,44 @@ public class MAuthorizationAccount extends X_AD_AuthorizationAccount {
|
||||||
* Synchronize information on other accounts with same email in the same credential
|
* Synchronize information on other accounts with same email in the same credential
|
||||||
*/
|
*/
|
||||||
public void syncOthers() {
|
public void syncOthers() {
|
||||||
final String script = "UPDATE AD_AuthorizationAccount "
|
final String clientSql =
|
||||||
+ "SET AccessToken=?, AccessTokenTimestamp=?, ExpireInSeconds=? "
|
"SELECT DISTINCT AD_Client_ID "
|
||||||
|
+ "FROM AD_AuthorizationAccount "
|
||||||
+ "WHERE AD_AuthorizationAccount_ID!=? "
|
+ "WHERE AD_AuthorizationAccount_ID!=? "
|
||||||
+ "AND EMail=? "
|
+ "AND EMail=? "
|
||||||
+ "AND AD_AuthorizationCredential_ID=? "
|
+ "AND AD_AuthorizationCredential_ID=? "
|
||||||
+ "AND IsAuthorized='Y' "
|
+ "AND IsAuthorized='Y' "
|
||||||
+ "AND RefreshToken IS NOT NULL";
|
+ "AND RefreshToken IS NOT NULL";
|
||||||
String accessToken = getAccessToken();
|
int[] clientIds = DB.getIDsEx(get_TrxName(), clientSql,
|
||||||
accessToken = SecureEngine.encrypt(accessToken, getAD_Client_ID());
|
|
||||||
DB.executeUpdateEx(script.toString(), new Object[] {
|
|
||||||
accessToken,
|
|
||||||
getAccessTokenTimestamp(),
|
|
||||||
getExpireInSeconds(),
|
|
||||||
getAD_AuthorizationAccount_ID(),
|
getAD_AuthorizationAccount_ID(),
|
||||||
getEMail(),
|
getEMail(),
|
||||||
getAD_AuthorizationCredential_ID()
|
getAD_AuthorizationCredential_ID());
|
||||||
},
|
if (clientIds.length > 0) {
|
||||||
get_TrxName());
|
final String script = "UPDATE AD_AuthorizationAccount "
|
||||||
|
+ "SET AccessToken=?, AccessTokenTimestamp=?, ExpireInSeconds=? "
|
||||||
|
+ "WHERE AD_AuthorizationAccount_ID!=? "
|
||||||
|
+ "AND EMail=? "
|
||||||
|
+ "AND AD_AuthorizationCredential_ID=? "
|
||||||
|
+ "AND IsAuthorized='Y' "
|
||||||
|
+ "AND RefreshToken IS NOT NULL "
|
||||||
|
+ "AND AD_Client_ID=?";
|
||||||
|
MColumn column = MColumn.get(getCtx(), Table_Name, COLUMNNAME_AccessToken);
|
||||||
|
for (int clientId : clientIds) {
|
||||||
|
String accessToken = getAccessToken();
|
||||||
|
if (column.isEncrypted())
|
||||||
|
accessToken = SecureEngine.encrypt(accessToken, clientId);
|
||||||
|
DB.executeUpdateEx(script.toString(), new Object[] {
|
||||||
|
accessToken,
|
||||||
|
getAccessTokenTimestamp(),
|
||||||
|
getExpireInSeconds(),
|
||||||
|
getAD_AuthorizationAccount_ID(),
|
||||||
|
getEMail(),
|
||||||
|
getAD_AuthorizationCredential_ID(),
|
||||||
|
clientId
|
||||||
|
},
|
||||||
|
get_TrxName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue