Fix some timezone bugs.

This commit is contained in:
MarkBryanMilligan
2021-03-06 15:45:09 -06:00
parent 181513c06d
commit a43222049d
7 changed files with 60 additions and 15 deletions

View File

@@ -41,6 +41,7 @@ public interface CurrentMonitorDao {
Account getAccount(int _accountId);
Account getAccountByUsername(String _username);
TimeZone getTimeZoneForAccount(int _accountId);
String getTimeZoneForAccount(String _authCode);
MongoProxy getProxy();
}

View File

@@ -200,7 +200,7 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
Account acct = proxy.queryOne(Account.class, new DaoQuery("username", _username));
if ((acct == null) || !BCrypt.checkpw(_password, acct.getPassword()))
return null;
return aes.encryptToBase64(DaoSerializer.toZipBson(new AuthCode(acct.getId(), acct.getAuxiliaryAccountIds())));
return toAuthCode(acct.getId(), acct.getAuxiliaryAccountIds());
}
@Override
@@ -226,7 +226,13 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
account.setTimezone(_tz.getID());
putAccount(account);
}
return aes.encryptToBase64(DaoSerializer.toZipBson(new AuthCode(account.getId(), account.getAuxiliaryAccountIds())));
return toAuthCode(account.getId(), account.getAuxiliaryAccountIds());
}
public String toAuthCode(int _acctId, List<Integer> _auxAcctIds) {
if (_acctId < 1)
return null;
return aes.encryptToBase64(DaoSerializer.toZipBson(new AuthCode(_acctId, _auxAcctIds)));
}
@Override
@@ -275,6 +281,14 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
return tz == null ? TimeZone.getTimeZone("America/Chicago") : tz;
}
@Override
public String getTimeZoneForAccount(String _authCode) {
AuthCode code = decryptAuthCode(_authCode);
if (code == null)
return null;
return getTimeZoneForAccount(code.getAccountId()).getID();
}
private Account clearPassword(Account _account) {
if (_account == null)
return null;