mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Fix some timezone bugs.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user