mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Password reset functionality, ZWave switch schedule improvement, support zwave controller on pi, support relay switches and security sensors.
This commit is contained in:
@@ -32,6 +32,9 @@ public interface CurrentMonitorDao {
|
||||
|
||||
void updateSummaries(BreakerGroup _rootGroup, Set<Date> _daysToSummarize, TimeZone _tz);
|
||||
|
||||
String addPasswordResetKey(String _email);
|
||||
String getEmailForResetKey(String _key);
|
||||
boolean resetPassword(String _key, String _password);
|
||||
String authenticateAccount(String _username, String _password);
|
||||
String getAuthCodeForEmail(String _email, TimeZone _tz);
|
||||
Account authCodeToAccount(String _authCode);
|
||||
|
||||
@@ -296,6 +296,32 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
|
||||
return _account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addPasswordResetKey(String _email) {
|
||||
String key = aes.encryptToBase64(_email);
|
||||
proxy.saveEntity("password_reset", new DaoEntity("_id", key));
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEmailForResetKey(String _key) {
|
||||
DaoEntity entity = proxy.queryForEntity("password_reset", new DaoQuery("_id", _key));
|
||||
if (entity == null)
|
||||
return null;
|
||||
return aes.decryptFromBase64ToString(_key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resetPassword(String _key, String _password) {
|
||||
DaoEntity entity = proxy.queryForEntity("password_reset", new DaoQuery("_id", _key));
|
||||
if (entity == null)
|
||||
return false;
|
||||
Account acct = getAccountByUsername(aes.decryptFromBase64ToString(_key));
|
||||
acct.setPassword(_password);
|
||||
putAccount(acct);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MongoProxy getProxy() {
|
||||
return proxy;
|
||||
|
||||
Reference in New Issue
Block a user